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

pdb and/or ipdb support #65

Open
jjlee opened this issue Aug 5, 2019 · 0 comments
Open

pdb and/or ipdb support #65

jjlee opened this issue Aug 5, 2019 · 0 comments

Comments

@jjlee
Copy link

jjlee commented Aug 5, 2019

  • PrettyPrinter version: 0.18.0
  • Python version: 3.7.3

Description

It would be great if pdb and/or ipdb were supported via the pp debugger command (or a new debugger command that has similar behaviour). My uninformed guess is that ipdb may be more open to extension in this way, but it may be that pdb can be monkey-patched.

Right now I use this function:

installed = False
def pp(*args, **kwds):
    global installed
    if not installed:
        prettyprinter.install_extras(include=["dataclasses"])
    return prettyprinter.pprint(*args, **kwds)

Then I have to import it using the ! debugger command, then pretty print again using that command, like:

(Pdb) !from myutils import pp
(Pdb) !pp(foo)

This works fine, but it's clunky if you run the debugger more than a few times.

What I Did

  1. Add an import pdb; pdb.set_trace() in some code
  2. Run the code
  3. When you see the pdb prompt, print something using the pp command (NOT the pp function above):
(Pdb) pp foo

Expect: output printed using prettyprinter.
Got: output printed using module pprint.

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