Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- x = 5
- # Uso de la variable libre `x`:
- sumar1 = lambda a: a + x
- x = 7
- sumar2 = lambda a: a + x
- print(sumar1(20))
- print(sumar2(20))
- # Captura de la variable libre `x` como un valor por defecto:
- x = 5
- sumar1 = lambda a, x = x: a + x
- x = 7
- sumar2 = lambda a, x = x: a + x
- print(sumar1(20))
- print(sumar2(20))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement