[Python-Dev] PEP 572: Assignment Expressions

Terry Reedy tjreedy at udel.edu
Tue Apr 17 18:05:41 EDT 2018


On 4/17/2018 1:03 PM, Yury Selivanov wrote:

> Using inline assignments in "while" statements is neat, but how
> often do we use "while" statements?

Beginners commonly write game and entry loops and commonly stumble over 
the need to write an infinite loop and a half.  The evidence is on both 
python-list and StackOverflow.  Reducing 4 lines to 1 here reduces 
complexity and, I think, increases clarity.

> 2. We all try to follow the Python zen when we are designing new
> language features.  With the exception of string formatting Python
> follows the "There should be one-- and preferably only one --
> obvious way to do it." line.

There is currently no way, not one way, to bind a name to an expression 
for use within the same statement.  I recommended to Chris that he 
remove from the PEP everything but this.  No other targets.  No 
chaining. (And no redefining class-scope comprehensions.)  This would 
remove all but the unavoidable overlap and reduce the added complexity 
of what people could write.

> I simply don't see a very compelling use case to have two forms
> of assignment in Python.

We already have more than two ;-).


-- 
Terry Jan Reedy



More information about the Python-Dev mailing list