On Fri, May 6, 2011 at 5:12 PM, Ethan Furman <ethan@stoneleaf.us> wrote:
Brendan Moloney wrote:
dag.odenhall@gmail.com wrote:
I like this idea, except it's inconsistent with from-import-star, the latter which does *not* get you sub-packages or modules.
Georg Brandl [g.brandl@gmx.net] wrote:
And that's for a reason: it's not easy (I think it's even impossible, because for example individual submodules can change __path__) to determine all importable submodules of a package.
So ``import pkg.*`` would not have any behavior other than ``import pkg``.
When I said all _public_ sub-packages and modules I was referring to those
listed in the __all__ attribute of 'pkg'. Thus it would behave in the exact same way as from-import-star except you don't pollute the current namespace.
I'm not catching the vision -- could you put together a short example that would illustrate?
The idea is to be able to do operate witha single import when submodules would have to be implicited imported - like xml.etree.ElementTree : [gwidion@powerpuff ~]$ python Python 2.6.1 (r261:67515, Apr 12 2009, 04:14:16) [GCC 4.3.2] on linux2 Type "help", "copyright", "credits" or "license" for more information.
import xml xml.etree Traceback (most recent call last): File "<stdin>", line 1, in <module> AttributeError: 'module' object has no attribute 'etree' import xml.etree xml.etree.ElementTree Traceback (most recent call last): File "<stdin>", line 1, in <module> AttributeError: 'module' object has no attribute 'ElementTree' import xml.etree.ElementTree xml.etree.ElementTree <module 'xml.etree.ElementTree' from '/usr/lib64/python2.6/xml/etree/ElementTree.pyc'>
~Ethan~ _______________________________________________ Python-ideas mailing list Python-ideas@python.org http://mail.python.org/mailman/listinfo/python-ideas