[Python-Dev] PEP 572: Assignment Expressions (original) (raw)

Chris Angelico rosuav at gmail.com
Tue Apr 24 03:24:04 EDT 2018


On Tue, Apr 24, 2018 at 5:12 PM, Greg Ewing <greg.ewing at canterbury.ac.nz> wrote:

Chris Jerdonek wrote:

if (diff := x - xbase) and (g := gcd(diff, n)) > 1: "if diff, which we let equal x - xbase, and g, which ..." or "if diff, which we set equal to x - xbase, and g, which ...." or "if diff, which we define to be x - xbase, and g, which ...." or "if diff, which we define as x - xbase, and g, which ....." etc. How about "being" as a keyword: if (diff being x - xbase) and (g being gcd(diff, n)) > 1: return g An advantage is that you're not likely to be tempted to write diff being x - xbase on its own as a statement.

Considering that we have ':=', 'as', and 'from', I very much doubt that any proposal requiring a new keyword is going to fly. The bar for creating new keywords is a lot higher than that. We hashed out a lot of this on python-ideas; it's almost certainly a waste of time to go through it all again now. I have no intention of editing the PEP to recommend a brand new keyword.

ChrisA



More information about the Python-Dev mailing list