On Tue, 24 May 2022 at 15:42, Jan Costandius <jcostand...@gmail.com> wrote:
>
> I think that it would be beneficial for PEP 8 conformance, in the case of 
> large nested dicts, if one were able to separate dict indices by a newline. 
> What I mean is shown below:
>
> foo["bar"]
>      ["baz"]
>      ["eggs"]
>      ["spam"] = 1

I don't think this looks particularly nice, nor do I see how it helps
with PEP 8. And if the keys are very long, naming the sub-parts is
perfectly viable:

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

and backslashes, while not particularly attractive, do the job just fine:

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

Do you have a real-world example of when this would be useful?
Something that doesn't use "fake" keys like bar or baz?

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

Reply via email to