Consider the two following files:
test.py:
import sys
def testfunction(string):
print(string)
sys.exit(0)
test2.py:
from test import testfunction
testfunction("string")
I would expect the import of testfunction not to execute statements outside of that function, e.g., sys.exit(0). Why is this happening, and how can I prevent it?