This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author doerwalter
Recipients
Date 2001-05-16.18:19:05
SpamBayes Score
Marked as misclassified
Message-id
In-reply-to
Content
This patch adds an optional parameter to the six 
methods (string|unicode).(|r|l)strip: This parameter, 
when given (and not None) specifies which string 
should be stripped (this works analogous to 
(string|unicode).split where the separator can be 
specified).

Example
"  spam  \r\n\r\n".rstrip("\r\n") => "  spam  "

When the parameter is not specified or None, the
behaviour is the old one: Strip any whitespace 
character.

The functionality is exposed on the C level as two
functions:

PyString_Strip(PyOb *self, PyOb *strip, int left, int 
right)
PyUnicode_Strip(PyOb *self, PyOb *strip, int left, int 
right)

("spam".strip(u"m") yields u"spa", which is the 
analogous behaviour of string.split: "spam eggs".split
(u" ") yields [u"spam", u"eggs"])

string.py and UserString.py are updated accordingly.

A patch to the documentation and additional test cases
in Lib/test/test_string.py and 
Lib/test/test_unicode.py are included.
History
Date User Action Args
2007-08-23 15:05:45adminlinkissue424606 messages
2007-08-23 15:05:45admincreate