I have to files in the same folder
First: (module1.py)
a = 2*np.pi
Second: (MainProg.py)
import numpy as np
from module1 import a
print(np.pi)
print(a)
When running MainProg.py the error tells me that name np in np.pi is not defined in module1.py. Do I have to extra import numpy as np in modul1.py?
Yes you have to.
Why ? because when you import a file in python, this file will be executed. So when your "module1.py" will be executed it will return you an error because "np" is inexistent.
EDIT: Don't see the import in python as a code replacement of the file you imported in your current file. The import will import functions that are in the file you are importing, and execute all codes that is not inside a python function or in the __main__.