extraneous import statements needed
Peter Hansen
peter at engcorp.com
Tue May 7 23:19:28 EDT 2002
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.
> I can fix it easily by just adding imports at the top of my class methods
> until I don't get any more errors, but that doesn't help me understand
> what's wrong.
You're way on the wrong track with that. This has nothing to do
with imports per se, but with some other bug.
> Sorry I didn't include an example, but as I said it seemed inconsistant
> and I have not (yet) been able to narrow down the cause or a good
> example/test case.
Don't worry about a test case. Just wait for the next time it
hits the problem and grab the exception traceback, paste it into
a message, and repost it here. We should be able to give you good
guidance on narrowing it down at that point.
-Peter
More information about the Python-list
mailing list