1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
x = 100 def parent(): x = 200 print 'parent-',x def child(): global x x+=1 print 'child-',x child() print 'parent-',x print '<module>',x parent() print '<module>',x """ output: <module> 100 parent- 200 child- 101 parent- 200 <module> 101 """