[Python-ideas] Allow multiple imports from a package while preserving its namespace

Paul Moore p.f.moore at gmail.com
Thu Apr 26 09:37:28 EDT 2018


On 26 April 2018 at 14:29, Julian DeMille via Python-ideas
<python-ideas at 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>"? I get that
it will mean that *only* the names listed will be accessible as
<lib>.<mod>, but I don't see why that's important (and specifically
why it's important enough to warrant dedicated syntax). Hiding names
in a namespace isn't typically something that Python provides language
support for.

Paul


More information about the Python-ideas mailing list