Skip to content

Allow chaining assignment expressions with fewer parentheses. #490

@pavelbraginskiy

Description

@pavelbraginskiy

Python 3.8's := operator has low precedence in resolves left-to-right, however there is anything at all left of := other than a name, it is always an error.
This makes expressions such as (a := b := c) impossible, requiring one to write (a := (b := c)) instead, which doesn't look as nice and requires more typing. It also mirrors the a = b = c statement that already exists in Python.
Coconut could be made to add the parentheses in for you, allowing such expressions - essentially resolving := right-to-left instead.

If := is also given higher precedence, it could allow expressions in the form (3 + a := b), currently accomplished by (3 + (a := b)), however I can see the argument that this kind of expression is harder to read without parentheses.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions