extraneous import statements needed
Jeff Davis
jdavis at empires.org
Mon May 6 18:08:21 EDT 2002
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).
However, this behavious does not seem consistant. I tried to narrow down
the cause of the failure, but all of the text cases I tried worked as I
expected (calling the split function of the string module that I imported
outside the class).
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.
Has anyone had a similar problem? I suppose it's a scoping issue, but
wouldn't I just get a NameError exception? How does it get set to None?
Did the outer import fail somehow maybe?
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. Since my methods are mostly dependent on eachother, it
is difficult to remove select parts without encountering an unrelated
error.
Thanks,
Jeff
More information about the Python-list
mailing list