x = 1 y = 0 def f(): x = 2 y = 3 def g(): global y x = 4 y = 5 print(' g returning with x =',x) print(' before f calls g x =',x) g() print(' f returning with x =',x) print('before f is called x =',x,'and y =', y) f() print('after f is called x =',x,'and y =', y) def changedict(): print(globals()) globals()['x'] = 'HACKED!' print(globals()) changedict() print('x =', x)