[Python-Dev] PEP 572: Assignment Expressions

Ethan Furman ethan at stoneleaf.us
Tue Apr 24 10:24:12 EDT 2018


On 04/23/2018 06:42 PM, Chris Jerdonek wrote:
> On Mon, Apr 23, 2018 at 4:54 PM, Greg Ewing wrote:
>> 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?
>
> It could be--
>
> "if diff, which we let equal x - x_base, and g, which ..." or
> "if diff, which we set equal to x - x_base, and g, which ...." or
> "if diff, which we define to be x - x_base, and g, which ...." or
> "if diff, which we define as x - x_base, and g, which ....." etc.

Thanks, Chris J.

For myself, I can read that as

"if diff, which is x - x_base, and g, which is ..."

That works for me.

Changing my vote to

+1  (but only for simple name bindings)

--
~Ethan~



More information about the Python-Dev mailing list