[Python-ideas] PEP 572: about the operator precedence of :=

M.-A. Lemburg mal at egenix.com
Thu May 10 12:29:33 EDT 2018

On 10.05.2018 15:57, Guido van Rossum wrote:
> On Thu, May 10, 2018 at 5:04 AM, M.-A. Lemburg <mal at egenix.com> 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

ohoh = a := (1, 2, 3), 4, a * 2


aha  = ((a := (1, 2, 3)), 4, a * 2)

You'd simplify the above logic to: the RHS of ":=" ends at the
nearest closing parenthesis.

> OT about the name: despite Tim's relentless pushing of "binding
> expressions" in the end I think they should be called "assignment
> expressions" just like in C.

Marc-Andre Lemburg

Professional Python Services directly from the Experts (#1, May 10 2018)
>>> Python Projects, Coaching and Consulting ...  http://www.egenix.com/
>>> Python Database Interfaces ...           http://products.egenix.com/
>>> Plone/Zope Database Interfaces ...           http://zope.egenix.com/

::: We implement business ideas - efficiently in both time and costs :::

   eGenix.com Software, Skills and Services GmbH  Pastor-Loeh-Str.48
    D-40764 Langenfeld, Germany. CEO Dipl.-Math. Marc-Andre Lemburg
           Registered at Amtsgericht Duesseldorf: HRB 46611

More information about the Python-ideas mailing list