AttributeError: 'function' object has no attribute 'split'

Peter Otten __peter__ at web.de
Thu May 6 13:05:31 EDT 2004


Earl wrote:

> PathList= string.split(FullPath, "/") is generating the above error
> message. when I run my script, but works just fine from the python
> command line!  What gives?

Either the FullPath is not a string:

>>> import string
>>> string.split(1, "/")
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
  File "/usr/local/lib/python2.3/string.py", line 121, in split
    return s.split(sep, maxsplit)
AttributeError: 'int' object has no attribute 'split'

Or you are using 'string' as a variable name:

>>> string = None
>>> string.split("abc/def", "/")
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
AttributeError: 'NoneType' object has no attribute 'split'

Peter




More information about the Python-list mailing list