I occasionally want to do something like this:

import .. as parent

or:

import . as self

The pattern is a little less useful for namespace packages (which I've been
trying to use almost exclusively, along with relative imports) than it is
for __init__.py based packages, but there is still some utility.

Is there a reason one can't import dots directly and bind them to a name? I
did not find any text around this and the closest I've come up with is:

from .. import __name__ as parent_module_name
parent = __import__(parent_module_name)

Could we support relative imports without `from` so long as there is an
`as`?

Thanks,

-- 

C Anthony
_______________________________________________
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