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.

classification
Title: (string|unicode).(|r|l)strip
Type: Stage:
Components: Library (Lib) Versions:
process
Status: closed Resolution: rejected
Dependencies: Superseder:
Assigned To: gvanrossum Nosy List: doerwalter, gvanrossum
Priority: normal Keywords: patch

Created on 2001-05-16 18:19 by doerwalter, last changed 2022-04-10 16:04 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
patch.txt doerwalter, 2001-05-16 18:19
patch.txt doerwalter, 2001-05-16 18:23 revised patch
Messages (3)
msg36605 - (view) Author: Walter Dörwald (doerwalter) * (Python committer) Date: 2001-05-16 18:19
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.
msg36606 - (view) Author: Walter Dörwald (doerwalter) * (Python committer) Date: 2001-05-16 18:23
Logged In: YES 
user_id=89016

Uups, the first patch had the function declarations in the 
wrong files.
msg36607 - (view) Author: Guido van Rossum (gvanrossum) * (Python committer) Date: 2001-08-09 17:50
Logged In: YES 
user_id=6380

I don't think this would be used enough to warrant the added
complexity.  Closing as Rejected.
History
Date User Action Args
2022-04-10 16:04:03adminsetgithub: 34511
2001-05-16 18:19:05doerwaltercreate