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

Chris Angelico rosuav at gmail.com
Fri Apr 13 00:55:35 EDT 2018


On Fri, Apr 13, 2018 at 2:37 PM, Guido van Rossum <guido at python.org> wrote:
> Clearly the PEP should spell out the precedence of :=. I'm sure Chris
> intended to give := the lowest possible precedence: the analogy with = (both
> in Python and in other languages), and the original design of the PEP, where
> the syntax was (<expr> as <var>), with mandatory parentheses. (Probably his
> implementation helps to guess his intention too, but I can't be bothered yet
> to clone and build it just to answer this question definitively. :-)
>
> I find the analogy argument compelling, and I think we should just make it a
> style rule that parentheses should be used whenever it could be misread by a
> human who's not sure about the precedence.
>
> Too bad for that one example.

Yes, that's the current intention, and (modulo a bug or two) the
current reference implementation. This may change tonight.

(If anyone's curious, and/or wants to join the discussion in
real-time, I'll be streaming live on https://twitch.tv/rosuav as I
tinker with the precedence.)

ChrisA


More information about the Python-ideas mailing list