Advertisement
Guest User

Untitled

a guest
Nov 26th, 2014
174
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.60 KB | None | 0 0
  1. def parent_function():
  2. y=10
  3. def child_function():
  4. print y
  5. child_function()
  6.  
  7. def receiving_function(f):
  8. f()
  9.  
  10. def parent_function():
  11. y=10
  12. def child_function():
  13. print y
  14. receiving_function(child_function)
  15.  
  16. >>> def parent_function():
  17. ... y=10
  18. ... def child_function():
  19. ... print y
  20. ... child_function()
  21.  
  22. >>> print y
  23. Traceback (most recent call last):
  24. File "<interactive input>", line 1, in <module>
  25. NameError: name 'y' is not defined
  26.  
  27. def func1():
  28. y=30
  29. def func2():
  30. print y
  31. func2()
  32.  
  33. def func2():
  34. print y
  35. def func1():
  36. y=30
  37. func2()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement