On 13 July 2018 at 23:36, Random832 <random...@fastmail.com> wrote: > On Wed, Jul 11, 2018, at 20:10, Guido van Rossum wrote: >> As anticippated, after a final round of feedback I am hereby accepting PEP >> 572, Assignment Expressions: https://www.python.org/dev/peps/pep-0572/ > > I know everyone else is probably sick of discussing this (I somehow > completely missed the discussion until it was almost done) but I have a > question... > > Why does this not allow assignment to attributes and subscripts? I think this > is, at least, surprising enough that there should be a rationale section > explaining it in the PEP. As it is, it's barely even explicitly stated, other > than the use of 'NAME' in a few places and an offhand mention "and [the > assignment statement] can assign to attributes and subscripts."
It's in the same category as disallowing assignment to attributes and subscripts in other name binding operations like "def" and "class" statements: there isn't a technical limitation preventing it, there's a design decision that we currently believe allowing it would reduce code clarity rather than increase it. It's also the case that unlike local name bindings, assigning to attributes and subscripts as an expression can already be formulated as a helper function with side effects. Cheers, Nick. -- Nick Coghlan | ncogh...@gmail.com | Brisbane, Australia _______________________________________________ Python-Dev mailing list Python-Dev@python.org https://mail.python.org/mailman/listinfo/python-dev Unsubscribe: https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com