error in string module documentation?

David Lewis DavidMLewis.NO at SPAM.mac.com
Sat Apr 19 06:50:40 EDT 2003


In article <mailman.1050740611.30741.python-list at python.org>, Michael
Anckaert <xantor at linux.be> wrote:

> Hello all,
> In the string module documentation I read the following:
> 
> 
> lstrip(s[, chars])
>         Return a copy of the string with leading 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 beginning of the string
>         this method is called on.
>         
> But I get the following error from my program:
> 
>   File "./game.py", line 35, in run_game
>     item = string.lstrip(cmd, "look")
> TypeError: lstrip() takes exactly 1 argument (2 given)
> 
> Is there an error in the documentation or is it my error?

It looks like something is getting shadowed. Use of the string module
is no longer recommended, since 2.2. Now, you'd not import the string
module, but say:

   item = cmd.lstrip('look')

Hope this helps.

   David




More information about the Python-list mailing list