I have a problem where I am setting some global varaibles within a function. But when I go to access these global variables outside the function (in the main part of the script) those global varaibles were never set?
Why do the following global variables always equal 0
and not 1
? How can I set the global variables within my function?
currentUserClientID = 0
currentUserMaxLicences = 0
currentUserActivatedLicences = 0
def setGlobals():
currentUserClientID = 1
currentUserMaxLicences = 1
currentUserActivatedLicences = 1
print "Set Globals"
print currentUserClientID
print currentUserMaxLicences
print currentUserActivatedLicences
setGlobals()
print "Global Values"
print currentUserClientID
print currentUserMaxLicences
print currentUserActivatedLicences
Output:
Set Globals
1
1
1
Global Values
0
0
0