I have the following situation:
The first file, named a.py
contains:
var = 2
The second file, named b.py
contains:
def prnt():
print(var)
The third file, named c.py
contains:
from a import *
from b import *
prnt() # NameError: name 'var' is not defined
and raises the given error. I always thought that the import
statement basically "copies" code into the calling namespace, so it should be the same as:
var = 2
def prnt():
print(var)
prnt()
but apparently this is not the case. What am I missing?