R. David Murray added the comment:

> So it looks like if "import xyz.b" bahaves different depending on how 
> a.py was initially loaded as a script or imported from another module.

There are several differences between importing a module and running a script, 
one of which is what is on sys.path.  You constructed your example to mask the 
path difference.

You are getting hit by the difference between absolute and relative imports.  
How implicit relative imports behave are one of the other things that are 
different between running a file as a script and importing it.  This kind of 
confusion is one of the reasons implicit relative imports were dropped in 
Python3.  

If you add

  from __future__ import absolute_import

to the top of your a and t files, t will no longer produce an import error.

It could be that the documentation could be improved, but I'm not sure it is 
worth the effort for 2.7.  If there are statements in the 3.x docs that are 
incorrect now that implicit relative imports are gone, those would definitely 
be worth fixing.

----------
nosy: +r.david.murray

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

Reply via email to