[Python-Dev] Small feature request - optional argument for string.strip()

Aahz Maruch aahz@rahul.net
Sun, 29 Jul 2001 10:19:27 -0700 (PDT)

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.