I have recently come to understand that we can use the following as a shorthand for repr(x) in Python:
`x`
However, I have rarely seen this in practice. Is it considered to be bad practice or unpythonic? Or are there any other reasons for which it is rarely used?
I don't think many people would argue that it's Pythonic especially since it's been removed from Python3
Prior to that, I would never use it in real code. The problem being that quite a few developers didn't know what it was for, and it's not very easy to search for.
There has also been a move in Python3 to have .__next__() method instead of .next() for iterators, which strengthens the idea that repr(x) calls x.__repr__() etc.
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