I am new here and not 100% sure how to ask this question, so I’ll just dive right in. Should I use import statements at the beginning of every function that I write, import all the various modules / functions that I need for this function? i.e.
def func1()
import os.path
print func(2)
do something with os.path
def func2()
import os.path
do something with os.path
Will this increase memory overhead or other overhead, or will the import statement simply match the local name with the already loaded object? Is there a better way to do this? (Links to tutorials, etc. are welcome. I have been looking for some time, but cannot find a good answer to this question.)
source
share