Kristján Valur Jónsson added the comment:

While I'm happy that this is being ackowledged as a problem, I'm not sure 
changing the "import x from y" semantics is necessarily a good idea.  I mean, 
it is obvious to me that it means "import x, then getattr(x, "y")".  I presume 
that is the meaning most people associate with it.  Certainly, "y" can be any 
old module attribute.

To change it to actually fall back to a submodule, well. I suppose if you could 
explain it roughly like "y = getattr(x, 'y', x.y)"  then it would be ok.

But I can think of contrived examples where this could break things:
#a.py:
from .b import util

#b.py
from . import a
from .util import util

Because of the circular import order, b.util will not exist as an attribute on 
b when a does its import.  So a.util will end up being util instead of 
util.util as one might expect.

I'm basically saying that it is possible that the fallback to submodule will 
occur, where the successful getattr would occur later and return something 
different than the submodule.  Possible. But perhaps very much an edge case :)

----------

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

Reply via email to