There are at least three existing ways to already do this.

    (foo["bar"]
         ["baz"]
         ["eggs"]
         ["spam"]) = 1

    foo["bar"][
        "baz"][
        "eggs"][
        "spam"] = 1

    foo["bar"]\
         ["baz"]\
         ["eggs"]\
         ["spam"] = 1


I think the first one is the clear winner.

The difficulty with your proposal is that without the indent, it is 
ambiguous:

    foo["bar"]
    ["baz"]
    ["eggs"]
    ["spam"] = value

The first three lines of that are legal code. Pointless, but legal. It 
is only when we get to the last line, the assignment, that it fails, and 
only because the unpacking assignment target is a literal. If it were a 
name, it could succeed:

    [spam] = value  # succeeds with value = (1,) for example

unpacks `value` and assigns the results to the list of names `[spam]`.

So this syntax will *require* indentation to avoid the ambiguity. But 
that breaks the rule that indentation is only required for a block 
following a keyword such as class, def, for, if etc.

Okay, so perhaps it is not quite a hard rule, more of a convention or 
expectation, but *requiring* such indentation would still violate 
it. So given that there are already at least three adequate solutions to 
the problem, I don't see the need to complicate the language to support 
another.


-- 
Steve
_______________________________________________
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-le...@python.org
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at 
https://mail.python.org/archives/list/python-ideas@python.org/message/CASG7V5AN7BJCOXXCEYWD26LQOMFD3UJ/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to