problem with global scope after package import via __init__.py

Greg Ewing see_reply_address at something.invalid
Tue Aug 20 01:51:49 CEST 2002


Denis S. Otkidach wrote:

> 
> Be aware of circular import being a bad practice, it may lead to
> hard-to-debug errors.


It's not necessarily bad, it depends on how you go
about it. If you always "import Modulename" and then
qualify all the names you use from it, there usually
isn't any problem.

Another technique which is useful for avoiding
circular import problems is to place import statements
inside the functions where they're used, rather
than at the top of the module.

-- 
Greg Ewing, Computer Science Dept,
University of Canterbury,	
Christchurch, New Zealand
http://www.cosc.canterbury.ac.nz/~greg




More information about the Python-list mailing list