Suggestion/recommendation for dictionary formatting

Raymond Hettinger vze4rx4y at verizon.net
Sun Aug 24 22:48:26 EDT 2003


"John D." <lists at webcrunchers.com> wrote in message
news:mailman.1061773823.16870.python-list at python.org...
> I've experimented with this and concluded:
>
> {1:2, 3:4, 5:6, 7:8}
>
> is more readable than the current output:
>
> {1: 2, 3: 4, 5: 6, 7: 8}
>
> Removing the space after the colon more clearly
> shows the key:value pairings. The effect is less striking
> with longer and more complex items, but it is never detrimental.
>
> Summary of proposed change:
> ---------------------------
> Synopsis: Remove space after the colon in formatted dictionary dumps
> Purpose: Legibility improvement
> Effect on existant programs: Minimal -this is mostly cosmetic
> Difficulty of implementation: Trivial for one familiar with core code
> Security issues: None
>
> Comments anyone?

Here is one data point
-------------------------
An indicator of what is natural is to see the writing style used when creating
dictionaries in production code.  Grepping for { in python/lib/*.py, I see
that with only one exception (rfc822.py), all of the hardcoded dictionaries
use a space after the colon.


Raymond Hettinger






More information about the Python-list mailing list