string.split() documentation incorrect?

carroll at carroll at
Fri Apr 11 18:39:00 CEST 2003

On Fri, 11 Apr 2003 09:52:32 -0600, Jerry Seutter
<jerry.seutter at> wrote:

>I'm trying to use string.strip to remove the comma off the end of 
>a string, eg:
>string.strip("id INT NOT NULL,", ",")
>The current documentation says I can do this.  Python 2.2.2 gives
>the following error:
>>>> strip('  hello  ', ',')
>Traceback (most recent call last):
>  File "<stdin>", line 1, in ?
>TypeError: strip() takes exactly 1 argument (2 given)
>So, I think either the documentation is incorrect or there is 
>a bug.  Thoughts?

Yeah, it's a bug, bug number 697220.  See
there's a patch available.

However, use of the string module is deprecated in favor of methods of
the string class, which work as documented.  The string module only
calls the equivalent class method anyway, e.g., string.strip(s) turns
into s.strip().

Save yourself some trouble and use the class method directly, e.g.,
instead of these:

 >>> string.strip(s,",")
 >>> string.strip("id INT NOT NULL,",",")

use these:

 >>> s.strip(",")
 >>> "id INT NOT NULL,".strip(",")

More information about the Python-list mailing list