So recently while working with imports, I came across a weird scenario.
Given a code file calc.py with the code below:
#calc.py
def add (x, y):
return x + y
print ("peeping")
def subtract (x, y):
return x - y
I decide to import just the add function from this module and print result of the function.
#use-calc.py
from calc import add
print (add(4, 5))
The output also returns the results of the global print function.
peeping
9
Is this accepted behavior or it is something we need to fix ? if it is correct then any documentation for the same. I dint want to post this on the bug tracker as am not sure its a valid bug or its my misunderstanding of the language.