[Python-Dev] PEP 572: Assignment Expressions (original) (raw)
Greg Ewing greg.ewing at canterbury.ac.nz
Tue Apr 24 03:12:52 EDT 2018
- Previous message (by thread): [Python-Dev] PEP 572: Assignment Expressions
- Next message (by thread): [Python-Dev] PEP 572: Assignment Expressions
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
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 - x_base) 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 - x_base
on its own as a statement.
-- Greg
- Previous message (by thread): [Python-Dev] PEP 572: Assignment Expressions
- Next message (by thread): [Python-Dev] PEP 572: Assignment Expressions
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]