extraneous import statements needed

David Bolen db3l at fitlinxx.com
Tue May 7 23:04:29 EDT 2002


Jeff Davis <jdavis at empires.org> writes:

> 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). 

If your basically down to a line that uses "string.split" and that's
the one giving you that error, then it seems most logical that
something else is using the name "string" within your class instance
and hiding the global module, and that the instance variable is
referencing None at the point when it executes.

E.g., could you accidentally be using an instance (or class) variable
and calling it string?  Or if not obvious, could some external code be
injecting an instance variable by that name?

Without seeing some actual code and an example of the error, it's hard
to say much more at this point.  But if you can create the error (even
if in a complex case) you might try adding some debugging in front of
the line to dump your locals() and/or just "string" itself to try to
see what it is before use.  If reproducing the problem is difficult,
you could enclose each of your methods in a try/except block waiting
for this error and then doing some debugging at that point.

--
-- David
-- 
/-----------------------------------------------------------------------\
 \               David Bolen            \   E-mail: db3l at fitlinxx.com  /
  |             FitLinxx, Inc.            \  Phone: (203) 708-5192    |
 /  860 Canal Street, Stamford, CT  06902   \  Fax: (203) 316-5150     \
\-----------------------------------------------------------------------/



More information about the Python-list mailing list