Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def fn():
- n = 0
- def fn_closure():
- print('n = {}'.format(n))
- def obtener_n():
- return n
- def establecer_n(valor):
- nonlocal n
- n = valor
- fn_closure.obtener_n = obtener_n
- fn_closure.establecer_n = establecer_n
- return fn_closure
- f = fn()
- f()
- f.establecer_n(10)
- f()
- n = f.obtener_n()
- print(n)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement