On Mon, May 9, 2011 at 7:04 AM, Nick Coghlan <ncoghlan@gmail.com> wrote:
This is one of the reasons circular imports are such a pain - we pre-bind them in sys.modules, and remove them again if the import fails, but we don't currently do that in the parent package namespace, so circular imports sometimes work and sometime break depending not only on which names are accessed but also *how* they're accessed (e.g. in a/b/c.py, "import a.b.c" will work, "import a.b.c; c = a.b.c" will fail with AttributeError and "from a.b import c" will fail with ImportError).
Maybe that's something we could strive to fix?
I can see a case being made to provide that as a function in pkgutil (or perhaps importlib itself), but I don't see any reason to give it dedicated syntax.
+1 -- --Guido van Rossum (python.org/~guido)