I am running a python script file from a Virtual on/off device.
I declare a variable at the beginning of the script file - LOG. I declare it as a global at the start of a method (def) but when the method is called, I get a global variable not defined error. When I run the script within PyCharm, it works ok.
As per another forum message, I have tried stopping / starting the server.
Any ideas? I am new to Python so it it is possibly a newbie mistake but I have tested extensively in PyCharm.
cutdown script code :
import statements...
LOG = True
def log(_text):
global LOG
if LOG == False:
return
... code ...
def mainprocess():
log("Running mainprocess"
... code ...
mainprocess()