I get a NameError
during import of a function from a module concerning a function which is not even imported itself. Minimal example is:
test.py:
from test2 import test2_b
test2_b(arg=None)
test2.py:
def test2_a(arg=a):
print('HI_a')
def test2_b(arg=b):
print('HI_b')
Output of python test.py
:
Traceback (most recent call last):
File "test.py", line 1, in <module>
from test2 import test2_b
File "/home/test2.py", line 2, in <module>
def test2_a(arg=a):
NameError: name 'a' is not defined
Why is the NameError
referring to the function test2_a
(instead of test2_b
, for which indeed the error should be raised) if test2_a
is not even imported?