'strip' documentation for beginners <g>

Alex Martelli aleax at aleax.it
Tue Mar 4 13:41:10 CET 2003


Dan Rawson wrote:

> The documentation for string.strip states that it can take an optional
> second parameter, but it doesn't appear to work:

If it states that, that's a but in the documentation, I think.  The
strip method of strings DOES (at least in 2.2.2, I don't think that
worked in 2.2.1) -- but string.strip exists basically only for
backwards compatibility, thus it's reasonable to avoid enhancing
it with new features such as the optional "what am I stripping"
argument..

alex at lancelot bin]$ python2.2
Python 2.2.2 (#1, Oct 24 2002, 11:43:01)
[GCC 2.96 20000731 (Mandrake Linux 8.2 2.96-0.76mdk)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> 'ciao!'.strip('!')
'ciao'
>>> import string
>>> string.strip('ciao!', '!')
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
TypeError: strip() takes exactly 1 argument (2 given)
>>>


Alex





More information about the Python-list mailing list