prettyprinter icon indicating copy to clipboard operation
prettyprinter copied to clipboard

Formatting of dict keys depends on the length of the corresponding value

Open anntzer opened this issue 5 years ago • 0 comments

  • PrettyPrinter version: 0.17
  • Python version: 38
  • Operating System: linux

Description

As in the title.

What I Did

from prettyprinter import pprint
pprint({
    (1, 2, 3):
        "short string",
    (4, 5, 6):
        "a really long string, if you see what I mean, just padding it for "
        "the sake of it",
})

outputs

{
    (1, 2, 3): 'short string',
    (
        4,
        5,
        6
    ):
        'a really long string, if you see what I mean, just padding it for '
        'the sake of it'
}

I would argue that a single-line-printable key should not be forced use to multiline output even if the value needs multiline output (in other words, the layout in the source seems more legible to me).

anntzer avatar Aug 21 '20 16:08 anntzer