[Python-Dev] (name := expression) doesn't fit the narrative of PEP 20 (original) (raw)

Tim Peters tim.peters at gmail.com
Thu Apr 26 00:40:32 EDT 2018


[Raymond Hettinger <raymond.hettinger at gmail.com>]

After re-reading all the proposed code samples, I believe that adopting the PEP will make the language harder to teach to people who are not already software engineers.

Can you elaborate on that? I've used dozens of languages over the decades, most of which did have some form of embedded assignment. Yes, I'm a software engineer, but I've always pitched in on "help forums" too. One language feature conspicuous by absence in newbie confusions was, consistently, assignment expressions. Read any book or tutorial for such a language, and you'll find very little space devoted to them too.

What's to learn? If they understand "binding a name" at all (which they must to even begin to write a non-trivial program), the only twist is that a binding expression returns the value being bound. Binding expressions certainly wouldn't be the first thing to teach people. But by the time it would make sense to teach them, it's hard for me to grasp how a student could struggle with such a tiny variation on what they've already learned (all the subtleties are in what - exactly - "binding"means - which they already faced the first time they saw "j = 1").

To my eyes, the examples give ample opportunity for being misunderstood and will create a need to puzzle-out the intended semantics.

Some do, many don't. The same can be said of a great many constructs ;-)

...



More information about the Python-Dev mailing list