Tim Peters wrote:
if (diff := x - x_base) and (g := gcd(diff, n)) > 1:
return g
My problem with this is -- how do you read such code out loud?
From my Pascal days I'm used to reading ":=" as "becomes". So
this says:
"If diff becomes x - base and g becomes gcd(diff, n) is
greater than or equal to 1 then return g."
But "diff becomes x - base" is not what we're testing! That
makes it sound like the result of x - base may or may not
get assigned to diff, which is not what's happening at all.
The "as" variant makes more sense when you read it as an
English sentence:
if ((x - x_base) as diff) and ...
"If x - x_base (and by the way, I'm going to call that
diff so I can refer to it later) is not zero ..."
--
Greg
_______________________________________________
Python-Dev mailing list
[email protected]
https://mail.python.org/mailman/listinfo/python-dev
Unsubscribe:
https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com