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

carroll at tjc.com carroll at tjc.com
Fri Apr 11 02:57:21 EDT 2003


On 9 Apr 2003 12:42:44 -0700, chlump at yahoo.com (Daniel Gowans) wrote:

>>>> 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.

I get that, too, on string.strip(y,"'"), but y.strip("'") works fine:

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

Are you sure y.strip fails for you?  

The strip definition in string.py does not match the doc; it only
takes one argument:

  # Strip leading and trailing tabs and spaces
  def strip(s):
     """strip(s) -> string

     Return a copy of the string s with leading and trailing
     whitespace removed.

     """
     return s.strip()






More information about the Python-list mailing list