On 26 April 2018 at 23:37, Paul Moore <p.f.mo...@gmail.com> wrote:
> On 26 April 2018 at 14:29, Julian DeMille via Python-ideas
> <python-ideas@python.org> wrote:
>> I personally would like a feature where instead of doing `from ... import
>> ...` (which imports the specified items into the current namespace), one
>> could use something along the lines of `import <lib>.{ <mod1>, <mod2>, ...
>> }` such that the imported modules/attributes could be accessed as
>> `<lib>.<mod1>`, etc.
>
> What are the benefits of this over a simple "import <lib>"?

Forcing submodule imports would be the main thing, as at the moment,
you have to choose between repeating the base name multiple times
(once per submodule) or losing the hierarchical namespace.

So where:

    from pkg import mod1, mod2, mod3

bind "mod1", "mod2", and "mod3" in the current namespace, you might
instead write:

    from pkg import .mod1, .mod2, .mod3

to only bind "pkg" locally, but still make sure "pkg.mod1", "pkg.mod2"
and "pkg.mod3" all resolve at import time.

Cheers,
Nick.

-- 
Nick Coghlan   |   ncogh...@gmail.com   |   Brisbane, Australia
_______________________________________________
Python-ideas mailing list
Python-ideas@python.org
https://mail.python.org/mailman/listinfo/python-ideas
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to