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

truncated output #90

Open
petaflot opened this issue Nov 10, 2022 · 0 comments
Open

truncated output #90

petaflot opened this issue Nov 10, 2022 · 0 comments

Comments

@petaflot
Copy link

  • PrettyPrinter version: 3.10? couldn't find anything more specific
  • Python version: 3.10.8
  • Operating System: Gentoo

Description

pretty printer truncates data

# dict with PrettyPrinter:
{   0: defaultdict(<function <lambda> at 0x7fcf56d5c940>,
                   {   U: defaultdict(<function <lambda> at 0x7fcf56d5c940>,
                                      {   K: defaultdict(<function <lambda> at 0x7fcf56d5c940>,
                                                         {   None: defaultdict(<function <lambda> at 0x7fcf56d5c940>,
                                                                               {


# there clearly is some data missing!

# DICT with print():
{0: defaultdict(<function <lambda> at 0x7fe9c7c04940>, {U: defaultdict(<function <lambda> at 0x7fe9c7c04940>, {K: defaultdict(<function <lambda> at 0x7fe9c7c04940>, {None: defaultdict(<function <lambda> at 0x7fe9c7c04940>, {'UNKN_V': defaultdict(<function <lambda> at 0x7fe9c7c04940>, {}), V0: datetime.datetime(2022, 11, 10, 18, 31, 9, 743503), V1: datetime.datetime(2022, 11, 10, 18, 31, 9, 743503)}), V0: defaultdict(<function <lambda> at 0x7fe9c7c04940>, {'UNKN_V': defaultdict(<function <lambda> at 0x7fe9c7c04940>, {V0: 'now I know V'})}), V1: defaultdict(<function <lambda> at 0x7fe9c7c04940>, {'UNKN_V': defaultdict(<function <lambda> at 0x7fe9c7c04940>, {V1: 'now I know V'})})})})})}


# manually formatted:
{                                                                                                                                                                                                                                                                                       0: defaultdict(<function <lambda> at 0x7fe9c7c04940>,
        {                                                                                                                                                                                                                                                                                       U: defaultdict(<function <lambda> at 0x7fe9c7c04940>,                                                                                                                                                                                                                           {                                                                                                                                                                                                                                                                                       K: defaultdict(<function <lambda> at 0x7fe9c7c04940>,                                                                                                                                                                                                                           {       
                                None: defaultdict(<function <lambda> at 0x7fe9c7c04940>,
                                {       
                                        'UNKN_V': defaultdict(<function <lambda> at 0x7fe9c7c04940>, {}),
                                        V0: datetime.datetime(2022, 11, 10, 18, 31, 9, 743503),                                                                                                                                                                                                                         V1: datetime.datetime(2022, 11, 10, 18, 31, 9, 743503)                                                                                                                                                                                                                  }),                                                                                                                                                                                                                                                                             V0: defaultdict(<function <lambda> at 0x7fe9c7c04940>,                                                                                                                                                                                                                          {       
                                        'UNKN_V': defaultdict(<function <lambda> at 0x7fe9c7c04940>,
                                        {       
                                                V0: 'now I know V'
                                        })
                                }),
                                V1: defaultdict(<function <lambda> at 0x7fe9c7c04940>,
                                {       
                                        'UNKN_V': defaultdict(<function <lambda> at 0x7fe9c7c04940>,
                                        {       
                                                V1: 'now I know V'
                                        })
                                })
                        })
                })
        })
}

What I Did

from pprint import PrettyPrinter
pprint = PrettyPrinter(indent=4).pprint # also tried with other values for 'indent'
from collections import defaultdict
dd = lambda: defaultdict(dd)
ncache = {0: dd()}

ncache[0]['U']['K']['V0']['UNKN_V']['V0'] = 'now I know V'
ncache[0]['U']['K']['V1']['UNKN_V']['V1'] = 'now I know V'

pprint(ncache)
print(ncache)
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