On Sun, Jan 17, 2021 at 7:33 AM Larry Hastings <la...@hastings.org> wrote:
> If your imports are complicated, you could always hide them in a > function. I just tried this and it seems to work fine: > > def my_imports(): > global other_mod > import other_mod > > So, you could put all your imports in such a function, run it from inside > a "if typing.TYPE_CHECKING" block, and you'd have a convenient way of doing > all your imports from inside IPython too. > But static type checkers won't understand such imports. (Or is this about annotations used for other purposes? Then I suppose it's fine, but only as long as you completely give up static type checks for modules that use this idiom.) -- --Guido van Rossum (python.org/~guido) *Pronouns: he/him **(why is my pronoun here?)* <http://feministing.com/2015/02/03/how-using-they-as-a-singular-pronoun-can-change-the-world/>
_______________________________________________ Python-Dev mailing list -- python-dev@python.org To unsubscribe send an email to python-dev-le...@python.org https://mail.python.org/mailman3/lists/python-dev.python.org/ Message archived at https://mail.python.org/archives/list/python-dev@python.org/message/3I7UDD5VAKQJDFW22OKCEPV3G4UPKMZB/ Code of Conduct: http://python.org/psf/codeofconduct/