On Wed, 25 May 2022 at 01:08, Jeremiah Paige <ucod...@gmail.com> wrote:
>
> While that formatting does look nice, this would be a huge change to the 
> parser just to allow a new formatting style. Right now lines are only 
> logically joined if they appear between a pair of () [] or {}, or if the line 
> ends in a \. Besides the complication of joining lines under new 
> circumstances, all the current options have a marker that the parser knows 
> about before it encounters the newline. With this new proposal the parser 
> will have to walk an arbitrary number of lines ahead to determine if there 
> are going to be new indexing operations. That won't really work at all in the 
> REPL or any other line-fed interpreter loop.
>
> Currently you can add parentheses to get just about the same visual:
> (foo["bar"]
>       ["baz"]
>       ["eggs"]
>       ["spam"] = 1)
>

Not for assignment, unfortunately. And you can't cheat with := either,
since only simple names are permitted.

I don't often need to do deep assignment like this though. Is it
possible to put something into a variable?

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

And if it still needs to go over multiple lines, parens can work on that.

ChrisA
_______________________________________________
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/JOLP2C3MPOSYK6C3NVWBG6GWRFUHQTCD/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to