Small feature request - optional argument for string.strip()
Is it OK to post small feature requests directly to this list, or is there some other mechanism for them? What I have in mind certainly isn't worth a PEP. 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) 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 file you could do:
fred = '**word**word**' fred.strip('*') word**word
Does this sound sensible/useful? Cheers, Simon Brunning. ----------------------------------------------------------------------- The information in this email is confidential and may be legally privileged. It is intended solely for the addressee. Access to this email by anyone else is unauthorised. If you are not the intended recipient, any disclosure, copying, distribution, or any action taken or omitted to be taken in reliance on it, is prohibited and may be unlawful. TriSystems Ltd. cannot accept liability for statements made which are clearly the senders own.
Is it OK to post small feature requests directly to this list, or is there some other mechanism for them? What I have in mind certainly isn't worth a PEP.
It's better to use the SF feture request tracker: http://sourceforge.net/tracker/?atid=355470&group_id=5470&func=browse
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) 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 file you could do:
fred = '**word**word**' fred.strip('*') word**word
Does this sound sensible/useful?
Marginally. --Guido van Rossum (home page: http://www.python.org/~guido/)
On 25 July 2001, Simon Brunning said:
fred = '**word**word**' fred.strip('*') word**word
Does this sound sensible/useful?
Not really. I can't recall ever having a need for such a feature in any programming language I've ever used. Greg -- Greg Ward - programmer-at-big gward@python.net http://starship.python.net/~gward/ I haven't lost my mind; I know exactly where I left it.
Simon Brunning wrote:
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) 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 file you could do:
fred = '**word**word**' fred.strip('*') word**word
Does this sound sensible/useful?
I've never seen a case where this was wanted except to delete *all* such characters. string.translate() does that, but in an awkward way. Perhaps a wrapper for string.translate() might make sense, called something like string.delete(). -- --- Aahz (@pobox.com) Hugs and backrubs -- I break Rule 6 <*> http://www.rahul.net/aahz/ Androgynous poly kinky vanilla queer het Pythonista I don't really mind a person having the last whine, but I do mind someone else having the last self-righteous whine.
participants (4)
-
aahz@rahul.net
-
Greg Ward
-
Guido van Rossum
-
Simon Brunning