'strip' documentation for beginners <g>
Dan Rawson
daniel.rawson.take!this!out! at asml.nl
Tue Mar 4 07:47:02 EST 2003
Alex Martelli wrote:
> 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
>
Thanks . . . . I couldn't find anything about it in the 2.2.2 release notes, but maybe I missed it.
More information about the Python-list
mailing list