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

Added prettyprint for dict modules #21

Closed
wants to merge 1 commit into from
Closed

Conversation

mithro
Copy link
Collaborator

@mithro mithro commented Dec 2, 2014

Another random addition which might be worth merging.

# Use pretty print for dictionaries
if isinstance(value, dict) or isinstance(value, list):
pp = self.pprint.PrettyPrinter(indent=0)
return pp.pformat(value)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dictionaries can be large so instead of returning here, I'd set value = pp.pformat(value)

Then value will be shortened if necessary by self.TEXT_REPR.repr() for inclusion in /tmp/q and the full value of value will be placed in a file.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And if we send to an external file, probably okay to leave an indent of 1 or 2 :-)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm.. but TextRepr.repr ends up escaping the pprint formatting which is not desirable. So it's not quite that simple :-(

@abadger
Copy link
Contributor

abadger commented Dec 5, 2014

Okay, here's a different take on pretty printing: https://gist.github.com/abadger/1db069b6127cc65e914d

What do you think? I can turn it into a pull request if you like it better than yours or you can just cherrypick the ideas that you like :-)

I wasn't sure if going forward we're going to be pushing to this repo or the mithro repo (I noticed that the 2.5 release was created off of the mithro repo, thus my confusion).

mithro pushed a commit to mithro/q that referenced this pull request Jun 10, 2015
As discussed in zestyping#21 I've made some changes
to the pprint change proposed there.

* This will save long values into a separate file.

* This makes pprint of the variable the default.  I think this is a good idea
  because it will handle things like dicts nested within lists and other
  builtin types.
@mithro
Copy link
Collaborator Author

mithro commented Jun 10, 2015

The pretty printing changes have ended up in #28 now. Closing this pull request.

@mithro mithro closed this Jun 10, 2015
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

Successfully merging this pull request may close these issues.

3 participants