0

Does python have any suggestions on how highly nested calls should look? For example, here is an example:

handler = SAXEventHandler(
            target=to_dict(
                target=dict_filter(key='title', value='Brown Christmas', 
                    target=dict_filter(key='vendor_id', value='02528_MLNA', 
                        target=print_me()
                    )
                )
            )
        )

Though it could also be:

handler = SAXEventHandler(
  target=to_dict(target=dict_filter(key='title', value='Brown Christmas', 
  target=dict_filter(key='vendor_id', value='02528_MLNA', target=print_me()))))

Or any number of variations. Are there guidelines with how this should be done with code similar to the above?

David542
  • 104,438
  • 178
  • 489
  • 842
  • 1
    Did you look through [PEP8](https://www.python.org/dev/peps/pep-0008/)? – wwii Mar 07 '20 at 04:50
  • 1
    another option would be to use black, which will enforce a consistent style for this sort of thing (and other sorts of things) across your code. Even when I sometimes don't love the style, the most important thing is enforcing consistency everywhere. https://github.com/psf/black – Max Power Mar 07 '20 at 04:58
  • @wwii -- sure, conceptually it makes sense, but there's no example more than one level of nesting in it -- if there is and I'm missing it could you please point out where? – David542 Mar 07 '20 at 04:59
  • @MaxPower -- very cool, I had never seen that before, thanks for mentioning that. Here's an example of the nesting with it: https://imgur.com/a/9lIEYkg. – David542 Mar 07 '20 at 05:01
  • 1
    @MaxPower here's a good one too: https://github.com/google/yapf – David542 Mar 07 '20 at 05:03
  • hey thanks, I'll definitely check that out! – Max Power Mar 07 '20 at 05:07

0 Answers0