calc.py and the program main.py sit in the same folder. The program imports the module inside a function.
calc.py:
def double(n):
return n * 2
main.py:
import sys
def load():
import calc
return calc.double(4)
print(load(), "calc" in dir(), "calc" in sys.modules)
What does main.py print?Log in to join the discussion.
Loading…