Python: When making a function, where do I put my "import" stuff? -


this question has answer here:

i'm making function assignment right now, , used "sys" , 'random' in function. wondering acceptable place put "import ___" when you're making function? wanted know future reference if it's better put "import" inside function, or if should stay outside.

put imports @ top of file.

the time makes sense import things anywhere else, if you're doing conditionally, see if said library exists example.

from this answer:

pep 8 authoritatively states:

imports put @ top of file, after module comments , docstrings, , before module globals , constants.


Comments

Popular posts from this blog

javascript - Bootstrap Popover: iOS Safari strange behaviour -

Magento/PHP - Get phones on all members in a customer group -

session - Logging Out Using PHP -