Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def parent_function():
- y=10
- def child_function():
- print y
- child_function()
- def receiving_function(f):
- f()
- def parent_function():
- y=10
- def child_function():
- print y
- receiving_function(child_function)
- >>> def parent_function():
- ... y=10
- ... def child_function():
- ... print y
- ... child_function()
- >>> print y
- Traceback (most recent call last):
- File "<interactive input>", line 1, in <module>
- NameError: name 'y' is not defined
- def func1():
- y=30
- def func2():
- print y
- func2()
- def func2():
- print y
- def func1():
- y=30
- func2()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement