Python accent graves bad practice?
Asked Answered
A

1

6

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?

Automatism answered 11/10, 2012 at 0:57 Comment(3)
It was removed from Py3k. For me is enough reason not to use it.Numbersnumbfish
And they were deprecated because they are hard to read and verging on implicit when repr is so much more clear. See also #1673571Waste
It was totally worth it to save 4 characters when we were paying > $1/GB for harddrive space, now harddrives got cheaper. Noone cares much if you waste 0.0000004 centsDecode
D
7

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.

Decode answered 11/10, 2012 at 1:15 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.