I'm trying to split my python code into a few files :
file1.py
from file2 import *
var1 = 7
func_file2()
file2.py
def func_file2():
var2 = var1
So it says:
NameError: global name 'var1' is not defined
How can I fix that?
I tried to import file1 in file2.
*to import. It clutters your namespace and can cause funny problems when you have two variables with the same names or even variables that have the same name as built-in functions. Just a general tip.