Error using string.strip

Jeff jam at quark.emich.edu
Sat Jan 8 10:18:08 EST 2000


On Sat, Jan 08, 2000 at 10:05:11AM -0500, Eric Hausig wrote:
> Hello there,
> 
> I'm very new to Python.  (In fact, I'm walking through the tuturial
> right now!)
> 
> I'm getting the following message:
> 
> >>> string.strip('str') + 'ing'
> Traceback (innermost last):
>   File "<stdin>", line 1, in ?
> NameError: string
> >>>
> 
> I'm running Redhat 6.1 and have installed all of the dev rpms off the
> CD.   Is there some library I have to manually include?  If someone
> could give me a little insight, I would be thankful.  (PS - I'm
> currently a VB/SQL programmer trying to make the switch to Linux.  =)
> 
> Sincerely,
> 
> Eric Hausig
> aka Codeslave2k
> 


you need to 'import string' (import the 'string module') before you will
have access to the 'strip' function:

[jam at toast ~]$ python
Python 1.5.2 (#1, Sep 17 1999, 20:15:36)  [GCC egcs-2.91.66 19990314/Linux
(egcs- on linux-i386
Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam
>>> import string
>>> string.strip('str  ')+'ing'
'string'

have fun! ;)

regards,
J
-- 
|| visit gfd <http://quark.emich.edu/>
|| psa member -- <http://www.python.org/psa/> 
|| New Image Systems & Services, Inc. <http://www.newimage.com/>




More information about the Python-list mailing list