Hi all,
I would like to propose a potential addition to Python's `import` syntax that 
would improve clarity and ergonomics for cases where developers want both full 
module access *and* a local alias to a specific attribute within that module.

Currently, to get both behaviors, we typically write:
import module
optimize = module.optimize

This works fine, but it is slightly verbose and less explicit in intent.

I would like to explore syntax like:
import module with module.optimize as optimize
or possibly:
import module with (
    module.optimize as optimize,
    module.validate as check
)

The goal is to import the full module as usual, while simultaneously assigning 
a local name to a chosen sub-attribute all in a single declaration.

This strikes a balance between:
*Readability* (makes intensions clearer)
*Convenience* (avoids repetitive alias assignments)
*Maintainability* (discourages `from module import *`)

I am curious to hear whether this type of syntax has been considered before, or 
if it might be worth formalizing into a PEP. I would be happy to help develop a 
draft proposal if there is interest.

Thank you for reading.
-Omar
-- 
https://mail.python.org/mailman3//lists/python-list.python.org

Reply via email to