Greg Ewing wrote:
> Nick Coghlan wrote:
> 
>> Jim Fulton's example in that tracker issue shows that with a bit of
>> creativity you can provoke this behaviour *without* using a from-style
>> import. Torsten Bronger later brought up the same issue that Fredrik did
>> - it prevents some kinds of explicit relative import that look like they
>> should be fine.
> 
> I haven't been following this very closely, but if there's
> something that's making absolute and relative imports
> behave differently, I think it should be fixed. The only
> difference between an absolute and relative import of the
> same module should be the way you specify the module.

That's exactly the problem though. Because of the difference in the way
the target module is specified, the way it is looked up is different:

'import a.b.c' will look in sys.modules for "a.b.c", succeed and work,
even if "a.b.c" is in the process of being imported.

'from a.b import c' (or 'from . import c' in a subpackage of "a.b") will
only look in sys.modules for "a.b", and then look on that object for a
"c" attribute. The cached "a.b.c' module in sys.modules is ignored.

It doesn't appear to be an impossible problem to solve, but it probably
isn't going to be easy to fix in a backwards compatible way.

Cheers,
Nick.

-- 
Nick Coghlan   |   ncogh...@gmail.com   |   Brisbane, Australia
---------------------------------------------------------------
_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to