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

Paul Moore p.f.moore at gmail.com
Fri Apr 13 11:34:05 EDT 2018


On 13 April 2018 at 16:13, Guido van Rossum <guido at python.org> wrote:
> Regarding the precedence of :=, at this point the only acceptable outcome
> for me is one where at the statement level, := and = can be used
> interchangeably and will have the same meaning (except probably we wouldn't
> allow combining both in a chained assignment). Because then we can say "and
> you can use assignment in expressions too, except there you must use :=
> because = would be too easily confused with ==".
>
> Ideally this would allow all forms of = to be replaced with :=, even
> extended structure unpacking (a, b, *c := foo()).

If we're going this far, why not just replace assignment statements
with assignment expressions using := completely, and leave the current
assignment statement for backward compatibility only (to be removed at
some point following a deprecation period)? That's not rhetorical - if
you're taking this position, I genuinely don't know if you see any
remaining advantages to the assignment statement other than backward
compatibility.

Personally, I don't like the idea - but I'm not sure if that's just
because I'm so used to assignment as a statement that I'm reluctant to
accept change...

Paul


More information about the Python-ideas mailing list