On Fri, Apr 27, 2018 at 5:14 AM, Nick Coghlan <ncogh...@gmail.com> wrote:
> Taking this idea in a completely different direction: what if we were
> to take advantage of PEP 451 __spec__ attributes to enhance modules to
> natively support implicit on-demand imports before they give up and
> raise AttributeError? (Essentially making all submodule imports
> implicitly lazy if you don't explicitly import them - you'd only be
> *required* to explicitly import top level modules, with everything
> under that being an implementation detail of that top level package)

That might be interesting to explore.  It smells like something
related to the lazy import magic that Neil Shemenauer is working on.

On the plus side, it means one less thing for programmers to do.  On
the minus side, I find the imports at the top of the file to be a nice
catalog of external dependencies.  Implicitly importing submodules
would break that.

The idea might be not as useful since the programmer would have to use
the fully qualified name (relative to the "top-level" package).  So
why not just put that in the import statement?

-eric
_______________________________________________
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