Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unwanted class(...) style printing of scalar values #79

Open
naught101 opened this issue Oct 13, 2020 · 0 comments
Open

Unwanted class(...) style printing of scalar values #79

naught101 opened this issue Oct 13, 2020 · 0 comments

Comments

@naught101
Copy link

  • PrettyPrinter version: 0.18.0
  • Python version: 3.6.10
  • Operating System: Linux

Description

Printing a nested dictionary with strings/floats/ints at the bottom level, and it displays str(...) or int(...) instead of the actual value. Often this isn't particularly space saving, is far more cryptic, and doesn't look very pretty.

What I Did

d = {
    "level1": {
        "level2": {
            "level3": {
                "level4": {"bottom"}
            },
            "level3.1": "some",
            "level3.2": "irrelevant",
            "level3.3": "words to",
            "level3.4": "make this",
            "level3.5": "dictionary long",
        },
        "longlist": list(range(20))
    }
}

prettyprinter.pprint(d, depth=3, max_seq_len=5)                                                                                                                     
# Results in:
{
    'level1': {
        'level2': {
            'level3': {...},
            'level3.1': str(...),
            'level3.2': str(...),
            'level3.3': str(...),
            'level3.4': str(...)
            # ...and 1 more elements
        },
        'longlist': [
            int(...),
            int(...),
            int(...),
            int(...),
            int(...),
            # ...and 15 more elements
        ]
    }
}

It would be good if this could just show the values, instead of the class names.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant