Ram Rachum <cool...@cool-rr.com> added the comment:

David, I don't think you've read my message carefully enough. I'm well aware 
that there are other ways in Python to import than the `import` statement. I'm 
proposing that it doesn't matter.

I asked, "isn't a circular import when you try to import a module `foo` while 
in a lower stack level you haven't finished importing `foo` yet?" If this is 
true, then you just need to have some kind of flag for each module saying "This 
module is currently being imported", which you set to `True` when you start 
importing and back to `False` when you finished importing. (It doesn't have to 
look exactly like this, it could be a context manager, or alternatively a 
centralized list of all module that are currently in the middle of an import.) 
Then when you have an `ImportError`, you check whether the module that the user 
tried to import has that flag raised, and if so notify him that it's probably a 
circular import problem.

Will that work?

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue12583>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to