On Wed, Dec 2, 2020 at 2:29 AM Paul Sokolovsky <pmis...@gmail.com> wrote:
> def fun():
>     # Imports are not allowed at run-time
>     import mod2
>     # But you can re-import module previously imported at import-time.
>     import mod

Wait, what? No. No no no. Please do not do ANYTHING like this. Having
suffered under JavaScript's highly restrictive import system (and
actually been glad for it, since the alternative is far worse), I do
not want ANY version of Python to give up the full power of its import
system, including the ability for a module to be imported only when
it's actually needed. Imports inside functions allow a program to have
optional dependencies, or dependencies that might be slow to load (eg
numpy), and without that, even running your script with "--help" has
to process every single import in the entire file.

-1000.

ChrisA
_______________________________________________
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-le...@python.org
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at 
https://mail.python.org/archives/list/python-ideas@python.org/message/EP24L35CMMDBBYAFVPAP2T4FJNHFRG4T/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to