-----Original Message----- From: PJ Eby [mailto:pje@telecommunity.com] Sent: 4. apríl 2013 20:29 To: Guido van Rossum Cc: Kristján Valur Jónsson; Nick Coghlan; python-dev@python.org Subject: Re: [Python-Dev] relative import circular problem
So, this is actually an implementation quirk that could be fixed in a (somewhat) straightforward manner: by making "from a import b" succeed if 'a.b' is in sys.modules, the same way "import a.b" does. It would require a little bit of discussion to hash out the exact way to do it, but it could be done.
Yes, except that "from a import b" is not only used to import modules. It is pretty much defined to mean "b = getattr(a, 'b')". Consider this module: #foo.py # pull helper.helper from its implementation place from .helper import helper now, "from foo import helper" is expected to get the helper() function, not the helper module, but changing the semantics of the import statement would be "surprising". K