[Python-bugs-list] [ python-Feature Requests-444708 ] Optional argument for string.strip()
noreply@sourceforge.net
noreply@sourceforge.net
Wed, 06 Mar 2002 14:16:08 -0800
Feature Requests item #444708, was opened at 2001-07-26 01:35
You can respond by visiting:
http://sourceforge.net/tracker/?func=detail&atid=355470&aid=444708&group_id=5470
Category: None
Group: None
Status: Open
Resolution: None
Priority: 5
Submitted By: Simon Brunning (brunns)
Assigned to: Nobody/Anonymous (nobody)
Summary: Optional argument for string.strip()
Initial Comment:
The .split method on strings splits at whitespace by
default, but takes an optional argument allowing
splitting by other strings. The .strip method (and its
siblings), on the other hand, always strip whitespace.
On more than one occasion I would have found it useful
if these methods also took an optional argument
allowing other strings to be stripped. For example, to
strip, say, asterisks from a string you could do:
>>>fred = '**word**word**'
>>>fred.strip('*')
word**word
If nothing else, this would meany that we have a good
answer when people ask about a equivalent to
Perl's 'chomp' function - string.rstrip(os.linesep).
----------------------------------------------------------------------
Comment By: Sean 'Shaleh' Perry (shaleh)
Date: 2002-03-06 14:16
Message:
Logged In: YES
user_id=37132
why is string.replace() not sufficient?
----------------------------------------------------------------------
You can respond by visiting:
http://sourceforge.net/tracker/?func=detail&atid=355470&aid=444708&group_id=5470