Need help with string method

Remco Gerlich scarblac at
Fri Dec 29 12:02:58 EST 2000

jvanar1 at <jvanar1 at> wrote in comp.lang.python:
> I have a pretty dumb question here.  I can't seem to get any string
> methods working from *within* a script.  here is a super-simple example
> that yields an error
> >>import sys
> >>import string
> >>theString = 'This is a string'
> >>print theString.find('string')
> now this works fine from the python command line but gives an error
> when run as a script. Here is the error message:
> Traceback (innermost last):
>   File "./clean", line 18, in ?
>     print theString.find('string')
> AttributeError: 'string' object has no attribute 'find'

Version mismatch. I think you tried it with a 2.0 command line but the
script invokes the 1.5.2 interpreter (or similar). Try printing sys.version
from the script, and check the #! line (if it's on unix).

Remco Gerlich

More information about the Python-list mailing list