I have 2 files main.py and irc.py.
main.py
import irc var = 1 func()
irc.py
def func(): print var
When I try to run main.py, I get this error
NameError: global name 'var' not defined
How to make it work?
@Edit
I thought there was a better solution, but unfortunately the only thing I found was to make another file and import it into both files
main.py
import irc import another another.var = 1 irc.func()
irc.py
import another def func(): print another.var
another.py
var = 0
gr56
source share