[FIXED] python pdb automatic pretty-printing

Issue

I find myself doing this in pdb quite often:

import pprint
pprint.PrettyPrinter().pprint(variable_of_interest)

Is there a better way to pretty-print variables from pdb? I'm looking for something easier to type, and ideally something that's always available in pdb so I can use it anytime I'm debugging.


Solution

In pdb documentation at the section Debugger Commands:

pp expression

Like the p command, except the value of the expression is pretty-printed using the pprint module.



Answered By - enrico.bacis
Answer Checked By - Senaida (Python.Easybugfix Volunteer)

Related Posts

Post a Comment