On Wed, Oct 23, 2019 at 4:33 PM Serhiy Storchaka firstname.lastname@example.org wrote:
23.10.19 14:00, Steven D'Aprano пише:
So please do educate me Serhiy, which one is the One Obvious Way that we should all agree is the right thing to do?
If you need a constant number, the most obvious way is to write it as a number literal, not int('123'). If you need a constant string, the most obvious way is to write it as a string literal, not bytes([65, 66]).decode(). If you need a list of constant strings, the most obvious way is to write it as a list display consisting of string literals. It works in all Python versions.
The second way works too in all actual Python versions (starting from 1.6), and nobody will beat you if you use it in your code. It can save you few keystrokes. But it is less obvious and less general.
Can we agree on the reply from Serhiy and close this discussion?
The proposed change does not bring any advantage apart from few saved keystrokes and even that is questionable, because it makes the code more prone to misreading/misinterpretation.
I can parse separately quoted string literals in the list (especially when they are highlighted by syntax coloring) much faster than read the one big string literal, while doing the mental split, keeping in mind which separators the author decided to use to make the split, and filtering some hardcoded chars which would otherwise get cut off.