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

Jack Diederich jack at performancedrivers.com
Wed Apr 9 16:05:51 EDT 2003


On Wed, Apr 09, 2003 at 12:42:44PM -0700, Daniel Gowans wrote:
> 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!

I just checked my 2.2.1 and CVS HEAD versions of stringobject.c
for 2.2.1, it takes no args (and the docstring says it takes no args)
for 2.3 (CVS HEAD) it takes an optional argument

You might be looking at the docs for one version of python, and using another.
Or it could be a documentation incongruity in 2.2.2

try this in the interpreter

Python 2.2.1 (#4, Sep  1 2002, 20:16:35) 
[GCC 2.95.4 20011002 (Debian prerelease)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>a ="hi Mom!"
>>help(a.strip)
>>> help(a.strip)
Help on built-in function strip:

strip(...)
    S.strip() -> string
    
    Return a copy of the string S with leading and trailing
    whitespace removed.

>>> a.strip("!")
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
TypeError: strip() takes no arguments (1 given)





More information about the Python-list mailing list