Discussion:
AttributeError: 'function' object has no attribute 'split'
Peter Otten
2004-05-06 17:05:31 UTC
Permalink
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?
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'
string = None
string.split("abc/def", "/")
Traceback (most recent call last):
File "<stdin>", line 1, in ?
AttributeError: 'NoneType' object has no attribute 'split'

Peter
Richard Brodie
2004-05-06 16:57:06 UTC
Permalink
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?
Somehow you've bound the name "string" to a function e.g.
... return 'help'
...
string.split('1')
Traceback (most recent call last):
File "<interactive input>", line 1, in ?
AttributeError: 'function' object has no attribute 'split'

Let that be a lesson to you to never use meaningful variable names ;)
Earl
2004-05-06 16:45:49 UTC
Permalink
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?

Loading...