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

Discussion in 'Python' started by Earl, May 6, 2004.

  1. Earl

    Earl Guest

    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?
     
    Earl, May 6, 2004
    #1
    1. Advertisements

  2. 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 ;)
     
    Richard Brodie, May 6, 2004
    #2
    1. Advertisements

  3. Earl

    Peter Otten Guest

    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
     
    Peter Otten, May 6, 2004
    #3
    1. Advertisements

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 (here). After that, you can post your question and our members will help you out.