Message36605
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.
|
|
Date |
User |
Action |
Args |
2007-08-23 15:05:45 | admin | link | issue424606 messages |
2007-08-23 15:05:45 | admin | create | |
|