extraneous import statements needed
Jeff Shannon
jeff at ccvcorp.com
Wed May 8 12:56:33 EDT 2002
In article <3CD89940.22826002 at engcorp.com>, Peter Hansen says...
> Jeff Davis wrote:
> >
> > I created a module that is essentially one big class. At the top I have a
> > group of import statements (outside the class). Within my methods I call
> > functions such as string.split(). However, I get strage error messages
> > about "type None does not have attribute split" or something similar
> > (always thinks that the module name is instead a None object).
>
> You may have a variable called "string" which is hiding the module
> after you've imported it? In that case, calling "string.split()" is
> going to produce the error you described.
Another possible source of this error, considering the
implementation of string.split(), is that you're actually passing
in a None as the argument. The code for string.split() is
basically this:
### in module string.py ###
def split(s):
return s.split()
Of course, if you're running into this problem with anything
other than string methods, or if it happens when you pass
something that you *know* is a string, then this isn't the
problem, and odds are that you're shadowing your global module
names, as everyone else is suggesting. :)
--
Jeff Shannon
Technician/Programmer
Credit International
More information about the Python-list
mailing list