string() - Is this some kind of sick joke?

Daniel Gowans chlump at yahoo.com
Wed Apr 9 15:42:44 EDT 2003


There is some sick joke in the python 2.2.2 documentation I have. 
This is located in the ActivePython documentation:

strip(s[, chars]) 
  Return a copy of the string with leading and trailing characters
removed. If chars is omitted or None, whitespace characters are
removed. If given and not None, chars must be a string; the characters
in the string will be stripped from the both ends of the string this
method is called on.

The same goes (in the docs) for rstrip and lstrip.

But does it actually work that way?  No!

Observe from the 2.2.2 interpreter (and 2.2.1 in HPUX):

>>> y="'hello'"
>>> import string
>>> string.strip(y,"'")
Traceback (most recent call last):
  File "<interactive input>", line 1, in ?
TypeError: strip() takes exactly 1 argument (2 given)
>>> 

What gives?  Did I get the bogus version?  Is this wishful thinking
documentation?  I also tried  y.strip("'")  with the same results.

If this can't be done this way (oh, how I love chomp()) then is there
a simple, elegant way to do it?




More information about the Python-list mailing list