[Python-ideas] PEP8 dictionary indenting addition

Jelte Fennema me at jeltef.nl
Sat Oct 8 15:26:13 EDT 2016


I have an idea to improve indenting guidelines for dictionaries for better
readability: If a value in a dictionary literal is placed on a new line, it
should have (or at least be allowed to have) a n additional hanging indent.

Below is an example:

mydict = {'mykey':
              'a very very very very very long value',
          'secondkey': 'a short value',
          'thirdkey': 'a very very very '
              'long value that continues on the next line',
}


As opposed to this IMHO much less readable version:

mydict = {'mykey':
          'a very very very very very long value',
          'secondkey': 'a short value',
          'thirdkey': 'a very very very '
          'long value that continues on the next line',
}

As you can see it is much harder in the second version to distinguish
between keys and values.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20161008/e892a0c1/attachment.html>


More information about the Python-ideas mailing list