/ Published in: Python
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
globvar = 0 def set_globvar_to_one(): global globvar # Needed to modify global copy of globvar globvar = 1 def print_globvar(): print globvar # No need for global declaration to read value of globvar set_globvar_to_one() print_globvar() # Prints 1
URL: http://stackoverflow.com/questions/423379/global-variables-in-python