User Tools

Site Tools


python:py3scopes

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

python:py3scopes [2013/03/16 17:40] (current)
Line 1: Line 1:
 +=== VARIABLE SCOPES ===
  
 +<code python>
 +#​!/​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)
 +</​code>​
 +    ​
python/py3scopes.txt ยท Last modified: 2013/03/16 17:40 (external edit)