string.strip

Bengt Richter bokr at oz.net
Fri Nov 8 08:09:09 EST 2002


On Fri, 8 Nov 2002 10:46:32 -0000, Simon Brunning <SBrunning at trisystems.co.uk> wrote:

>> From:	Duncan Booth [SMTP:duncan at NOSPAMrcp.co.uk]
>> Gerhard H=E4ring <gerhard.haering at opus-gmbh.net> wrote:=20
>> > In article <mailman.1036744990.32317.python-list at python.org>, Stano
>> > Paska wrote:=20
>>=20
>> >> in documentation: string.strip(s[, chars])
>> >> but in real life strip takes only 1 parameter
>> >>=20
>> >> I have python 2.2.2
>> >=20
>> > But you've read the documentation for 2.3. (.../doc/current on
>> > python.org).=20
>>=20
>> Did you check your answer before posting?
>>=20
>> See
>> http://www.python.org/doc/2.2.2/lib/module-string.html#l2h-698
>=20
>Ah, but this is the string *module*. The string method page -
><http://www.python.org/doc/2.2.2/lib/string-methods.html> - looks =
>right. In
>fact, they both do.
>

 Python 2.2.2 (#37, Oct 14 2002, 17:02:34) [MSC 32 bit (Intel)] on win32
 Type "help", "copyright", "credits" or "license" for more information.
 >>> import string
 >>> print string.strip.__doc__
 strip(s) -> string

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


 >>> print str.strip.__doc__
 S.strip([sep]) -> string or unicode

 Return a copy of the string S with leading and trailing
 whitespace removed.
 If sep is given and not None, remove characters in sep instead.
 If sep is unicode, S will be converted to unicode before stripping

 >>> ' abc def  '.strip()
 'abc def'
 >>> ' abc def  '.strip('fa ')
 'bc de'
 >>> string.strip(' abc def  ')
 'abc def'
 >>> string.strip(' abc def  ','fa ')
 Traceback (most recent call last):
   File "<stdin>", line 1, in ?
 TypeError: strip() takes exactly 1 argument (2 given)

 >>> string.strip
 <function strip at 0x007DB3A0>
 >>> str.strip
 <method 'strip' of 'str' objects>
 >>>

Regards,
Bengt Richter



More information about the Python-list mailing list