[Patches] [ python-Patches-424606 ] (string|unicode).(|r|l)strip
noreply@sourceforge.net
noreply@sourceforge.net
Wed, 16 May 2001 11:19:07 -0700
Patches item #424606, was updated on 2001-05-16 11:19
You can respond by visiting:
http://sourceforge.net/tracker/?func=detail&atid=305470&aid=424606&group_id=5470
Category: Windows
Group: None
Status: Open
Resolution: None
Priority: 5
Submitted By: Walter Dörwald (doerwalter)
Assigned to: Nobody/Anonymous (nobody)
Summary: (string|unicode).(|r|l)strip
Initial Comment:
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.
----------------------------------------------------------------------
You can respond by visiting:
http://sourceforge.net/tracker/?func=detail&atid=305470&aid=424606&group_id=5470