[Python-Dev] PEP 572: Assignment Expressions

Paul Moore p.f.moore at gmail.com
Sat Apr 21 05:12:56 EDT 2018


On 21 April 2018 at 03:30, Chris Angelico <rosuav at gmail.com> wrote:
> There's that word "readability" again. Sometimes I wish the Zen of
> Python didn't use it, because everyone seems to think that "readable"
> means "code I like".

Readability is subjective, yes. But it's not the same as "liking". If
a significant number of people say that they find a piece of code hard
to read/understand, then that's a problem. It's all too easy to say
"you don't have to write code like that", but as someone who has been
a maintenance programmer for his whole career, I can tell you that
people don't always have that luxury. And supporting code that's
written in a language that prioritises "readability" (whatever that
may mean) is a much easier task than supporting code written in a
language that doesn't. There's a reason far fewer people write systems
in Perl these days, and it's not because you can't write clear and
maintainable code in Perl...

I think that enough people have flagged up readability concerns, that
the PEP should take that seriously. One improvement would be to limit
the proposal to assignment of simple names (there have been far fewer
complaints about readability for such examples). Another would be to
simply address the concern more seriously than the current "This can
be used to create ugly code" section. How about a heading like "Code
that uses this construct could be difficult to maintain", with a
discussion that acknowledges that maintenance programmers usually
didn't write the code, and sometimes don't have the freedom to rewrite
working code. It could mention other easy-to-misuse constructs like
over-complicated comprehensions, and point out that in practice things
haven't turned out as bad with those as was feared.

Paul.


More information about the Python-Dev mailing list