[Python-Dev] PEP 572: A backward step in readability

Steven D'Aprano steve at pearwood.info
Mon Apr 30 12:37:58 EDT 2018


On Mon, Apr 30, 2018 at 08:09:35AM +0100, Paddy McCarthy wrote:
[...]
> A PEP that can detract from readability; *readability*, a central
> tenet of Python, should
> be rejected, (on principle!), when such objections are treated so dismissively.

Unless you have an objective measurement of readability, that objection 
is mere subjective personal preference, and not one that everyone agrees 
with. I for one think that used wisely, binding expressions will be 
*more* readable than the alternatives. (Even though := is not my 
preferred syntax.)

The "not readable" objection has been made, extremely vehemently, 
against nearly all major syntax changes to Python:

- comprehensions? not readable, easy to abuse, hard for beginners
  to comprehend;

- decorators? not readable, looks like Perl with the arbitrary
  use of @ symbol, hard to understand;

- ternary if operator? not readable, doesn't look enough like C,
  weird order;

- augmented assignments += etc -- not readable, too terse, requires
  the reader to be familiar with C.

I was guilty of making that last one. And if I had been around for the 
debate over decorators, I probably would have hated them too. But all 
four additions to the syntax have been *great* for the language, despite 
the nay-sayers.

I still know people with many years experience in Python who say they 
don't get comprehensions, and of course it is true that they are hard 
for beginners to get. But the advantages from comprehensions is 
immeasurably greater than the disadvantages.

Will this PEP be like comprehensions or decorators, and completely 
change the way we write Python code (for the better)? I doubt it. But I 
expect it will be like augmented assignment and the ternary if: it will 
make certain kinds of code more pleasurable to write *and read*, and 
when it doesn't, people won't use it.


-- 
Steve


More information about the Python-Dev mailing list