I can’t be sure because you don’t show the entire file, but it seems you have global variable right ?
so it seems that you try to set a global variable inside a function. For this to work, you should use the keyword ‘global’
foo = 0
bar = 0 # global variable created
def wrong_func():
# create locals variables to 'wrong func' and set them
foo = 5
bar = 3
def right_func():
# 'import' the global variables
global foo
global bar
#set the global variables
foo = 5
bar = 3
foo = 0
bar = 0 # global variable created
def wrong_func():
# create locals variables to 'wrong func' and set them
foo = 5
bar = 3
def right_func():
# 'import' the global variables
global foo
global bar
#set the global variables
foo = 5
bar = 3
print foo
print bar