User Tools

Site Tools


python:py3scopes

VARIABLE SCOPES

#!/usr/bin/env python3.0
#
#       variable_scopes.py
#       
#       
# Example of variable scopes
 
 
def localExample():
    number1 = 123
    print ("This is local scope. Number",number1)
 
def globalExample():
    global number2
    number2 += 100
 
 
localExample()
 
number2 = 999
print('variable value:', number2)
globalExample()
print('variable value after globalExample() call:', number2)

python/py3scopes.txt · Last modified: 2013/03/16 17:40 (external edit)