Import problem

Achim Domma (Procoders) domma at procoders.net
Mon Nov 22 05:25:19 EST 2004


Hi,

in my __init__.py of module A.B if have something like:

from win32com.client import Dispatch
obj=Dispatch('...')
VERSION=tuple([int(x) for x in obj.Version.split('.')])
del obj

Now I should be able to write:

import A.B
if A.B.VERSION[0]=5:
     do_something()

but

from A.B import VERSION

does not work. Mysterious to me, but not a real problem. But now I have 
another problem. In my __init__.py I do something like this, after 
setting up my VERSION variable:

import _C
classA = _C.classA
classB = _C.classB

In _C I have to do some stuff depending on VERSION. Therefore I have in 
_C.py:

import A.B
if A.B.VERSION[0]==5:  <- Error
     do_something()

I get the error:
AttributeError: 'module' object has no attribute 'B'

Seems like I'm mixing up something in a very bad way, but I have no idea 
what I'm doing wrong!?

regards,
Achim



More information about the Python-list mailing list