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

Ivan Levkivskyi levkivskyi at gmail.com
Tue Apr 24 03:27:13 EDT 2018


On 24 April 2018 at 08:12, 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. I like this term, but I don't like having more reserved words. Or PEP can make it an official way to read :=

(z := x + y) is called a binding expression. (z := x + y) reads as "z being x + y"

-- Ivan -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://mail.python.org/pipermail/python-dev/attachments/20180424/190ef6d9/attachment.html>



More information about the Python-Dev mailing list