[EMAIL PROTECTED] wrote:
> How does one get access to the class that imported a module.  For example:
> foo imports bar -- how does bar access foo?
>
> Thanks.
>
>   

If bar wants to access foo, it just imports it. If foo imports bar as 
well, then you have circular imports, but Python can handle this with no 
problem.

There can be a problem with circular imports if you try to import 
specific names from the module, and the circularity happens before those 
names are defined. But just:
foo:
import bar
...

bar:
import foo
...
works fine.

However... as several others have pointed out, circular imports are 
often a sign that your software design is not very well thought out. 
It's usually better to have your thought process, your design and your 
imports organized in a hierarchal fashion.

Gary Herron




-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to