Cyclic imports

James at
Fri Jun 27 00:58:47 EDT 2008

> #
> import b
> # refer to b.b
> #
> import a
> # refer to a.a

Thanks Dan, but that still doesn't work for me I'm afraid...

I renamed the modules avoid name overloading -- is now:
import b

class A():
    print('b.b_mod:', b.b_mod)

b is now defined, but b.b_mod isn't:
  File "", line 1, in <module>
    from a import a_mod
  File "/Users/james/tmp/python/a/", line 3, in <module>
    class A():
  File "/Users/james/tmp/python/a/", line 4, in A
    print('b.b_mod:', b.b_mod)
AttributeError: 'module' object has no attribute 'b_mod'

I must be missing something here - I've tried adding the modules to
__all__ in but that didn't help either.


More information about the Python-list mailing list