here is my python code:
import numpy
class test:
def __init__(self,):
print(numpy.__version__)
if False:
numpy = None
if __name__=='__main__':
print(numpy.__version__)
T = test()
when I run this code, the interpreter give me an error showed blow:
UnboundLocalError: local variable 'numpy' referenced before assignment
It seems like, before executing numpy = None, imported module "numpy" has been covered while there is no numpy variable.
My question is what exactly the interpreter did during initializing a class(not object)?
numpy = None? This makes Python thinknumpyis a local variable.