[summerofcode] Problem in import
Ian Bicking
ianb at colorstudy.com
Thu Jul 14 17:25:56 CEST 2005
John Xiaogang Zhang wrote:
> import tilefilesys.tilefile.TFHandlers as TFHandlers
> AttributeError: 'module' object has no attribute 'TFHandlers'
>
> However, if I change the last file to
>
> import tilefilesys.tilefile.TFHandlers as TFHandlers
>
> that is, without the "as TFHandlers", then the errors gone (but I cannot
> refer it as the shorter reference).
>
> Could please anyone tell me why it happens, and how to get rid off it?
Looks like a circular import; probably you import tilefile from
somewhere, and tilefile imports this file, and this file then tries to
import tilefile. During that third import (the one with the error) the
tilefile module has not been fully loaded, so the TFHandlers object has
not yet been created.
You'll have to refactor your modules to avoid circular imports.
--
Ian Bicking / ianb at colorstudy.com / http://blog.ianbicking.org
More information about the summerofcode
mailing list