There are two py files. util.py
def add_sum():
print(x + 3)
test.py
from util import *
x=3
add_sum()
When I run test.py, I get error:
Traceback (most recent call last):
File "test.py", line 45, in <module>
add_sum()
File "util.py", line 10, in add_sum
print(x + 3)
NameError: name 'x' is not defined
The variable x is global, why function cannot reach x and raise error?
test.pyimporting itself?