On 15/06/2026 17:51, Chris Angelico via Python-list wrote:
On Tue, 16 Jun 2026 at 01:45, Jon Ribbens via Python-list
<[email protected]> wrote:
My biggest complaint about := is the arbitrary and mysterious
restrictions on what you can use on the left hand side. You can't
even say "a.b := c". The PEP that introduced ":=" barely even
mentions these restrictions, let alone discusses or explains them.
Perhaps it isn't obvious, but here's the part of the specification
that you're referring to:

https://peps.python.org/pep-0572/#syntax-and-semantics

"NAME is an identifier". It is that simple. It's not arbitrary or
mysterious. The rule is that the target must be an identifier. Nothing
more, nothing less. As to why, that's largely to avoid syntactic
ambiguities, although even so, certain usages with lambda functions
require parentheses.

But hey, if *that's* your biggest complaint, I'm glad it was so easy to answer!

ChrisA
Chris, you say the restriction is not arbitrary.  Well, it seems so to me.  Why not a.b := c # as Jon mentioned L[2:4] := M[3:5] L[3] := x (a,b) := (c,d) Of course these would be part of an expression, not complete lines of code. This very much reminds me of the rather stringent syntax restrictions that were initially put on decorators. Eventually these restrictions were removed. Best wishes Rob Cliffe
--
https://mail.python.org/mailman3//lists/python-list.python.org

Reply via email to