[Python-ideas] PEP 572: Assignment Expressions (post #4)

Brendan Barnwell brenbarn at brenbarn.net
Wed Apr 11 17:09:02 EDT 2018


On 2018-04-11 11:05, David Mertz wrote:
> How about this, Brendan?
>
> _, x1, x2 = (D := b**2 - 4*a*c), (-b + sqrt(D))/2, (-b - sqrt(D))/2
>
> I'm not sure I love this, but I don't hate it.

	That's clever, but why bother?  I can already do this with existing Python:

D = b**2 - 4*a*c
x1, x2 = (-b + sqrt(D)))/2, (-b - sqrt(D))/2

	If the new feature encourages people to do something like your example 
(or my earlier examples with the D definition inline in the expression 
for x1), then I'd consider that another mark against it.

-- 
Brendan Barnwell
"Do not follow where the path may lead.  Go, instead, where there is no 
path, and leave a trail."
    --author unknown


More information about the Python-ideas mailing list