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

E

Earl

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?
 
R

Richard Brodie

Earl said:
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'
....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 ;)
 
P

Peter Otten

Earl said:
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:
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:
Traceback (most recent call last):
File "<stdin>", line 1, in ?
AttributeError: 'NoneType' object has no attribute 'split'

Peter
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,535
Members
45,007
Latest member
obedient dusk

Latest Threads

Top