I was reading Hidden features of Python and I came across this answer.
Right from the post:
When using the interactive shell, "_" contains the value of the last printed item:
>>> range(10)
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
>>> _
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
>>>
What is the name of this operator ? I cannot find it on the document and I've never heard of it (as well as in other languages). Is it worth using it?
PS. I want to know its name because I want to see how the function is implemented and to search if other languages have this awesome function.
|= on Booleans The Python |= operator when applied to two Boolean values A and B performs the logical OR operation A | B and assigns the result to the first operand A . As a result, operand A is False if both A and B are False and True otherwise. What is this?
The <> operator has been removed from Python 3. ...and <> isn't mentioned in the v3 documentation at all. @ T.J. Crowder: Thanks for the clarification about the 2.
itemgetter (item) operator. itemgetter (*items) Return a callable object that fetches item from its operand using the operand's __getitem__() method. If multiple items are specified, returns a tuple of lookup values.
It's neither an operator nor a function. It's a variable that automatically gets assigned the result of each expression executed by the shell.
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