Return to Snippet

Revision: 32547
at September 28, 2010 22:24 by magicrebirth


Initial Code
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

Initial URL
http://stackoverflow.com/questions/423379/global-variables-in-python

Initial Description

                                

Initial Title
Global variables in Python

Initial Tags

                                

Initial Language
Python