[Python-ideas] PEP 572: about the operator precedence of :=
Ethan Furman
ethan at stoneleaf.us
Thu May 10 12:38:17 EDT 2018
On 05/10/2018 09:29 AM, M.-A. Lemburg wrote:
> On 10.05.2018 15:57, Guido van Rossum wrote:
>> On Thu, May 10, 2018 at 5:04 AM, M.-A. Lemburg wrote:
>>> To a (former Pascal) programmer, a := 1 doesn't read like an
>>> operator. It's an assignment expression. If embedded expressions
>>> is where Python is heading, it should be made very clear where
>>> the embedded expression starts and where it ends on a line.
>>>
>>
>> The rules we've arrived at are about as straightforward as it gets: the RHS
>> of `:=` ends at the nearest comma or close parenthesis/bracket/brace.
>
> That may be easy for a computer to parse, but it's not for
> a programmer. It would be better to contain such expressions
> inside a safe container which is clearly visible to a human
> eye.
>
> ohoh = a := (1, 2, 3), 4, a * 2
I have no problem reading that.
> vs.
>
> aha = ((a := (1, 2, 3)), 4, a * 2)
The extra parens are unneeded line noise (at least for me).
--
~Ethan~
More information about the Python-ideas
mailing list