[Python-Dev] intra-package mutual imports fail: "from <pkg> import <mod>"

Guido van Rossum guido@python.org
Mon, 03 Jun 2002 10:21:04 -0400


> Um, different problem. What Matthias explains is
> unavoidable. But in David's case, the containing
> namespace (the package) is not empty when 
> module2 wants module1.  In fact, I believe that
> sys.modules['package.module1'] is there (though
> *it* is empty).
> 
> My guess is that import is looking for module1
> as an attribute of package, and that that binding
> hasn't taken place yet.

Yes, that's what "from package import module" does -- it wants
"module" to be an attribute of "package".  This is because it doesn't
really distinguish between "from package import module" and "from
module import attribute".

--Guido van Rossum (home page: http://www.python.org/~guido/)