So, I'm confused. I have a module containing some function that I use in another module. Imported like so:
from <module> import *
Inside my module, there exist functions whose purpose is to set global variables in the main program.
main.py:
from functions import *
bar = 20
print bar
changeBar()
print bar
functions.py:
def changeBarHelper(variable):
variable = variable * 2
return variable
def changeBar():
global bar
bar = changeBarHelper(bar)
Now, this is a simplification, but it is the least code that yields the same result:
Traceback (most recent call last):
File "/path/main.py", line 5, in
changeBar()
File "/path/functions.py", line 7, in changeBar
bar = changeBarHelper(bar)
NameError: global name 'bar' is not defined