If you are familiar with Matlab, there is a global variable ans
that captures the first return value of a function that is not assigned to any particular variable. Is there any matching construct in Python?
"Least Astonishment" and the Mutable Default Argument. 709. 3588. 2115.
Matlab is faster than Python, but Python is better at running multiple jobs in parallel.
You’re looking for _
:
>>> 1+1
2
>>> _
2
>>> def f(x):
... return x+1
...
>>> f(3)
4
>>> _
4
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With