python pdb automatic pretty-printing
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.
Once you are in (Pdb) shell:
(Pdb)$ import pprint
# then you can pretty print your variables.
(Pdb)$ pp( locals() )
(Pdb)$ pp(request.data)
Also, I recommend using the new pdb alternative breakpoint()
, that way you don't have to import pdb package in any of your dev environment sourcecode. It's also easier to type than pdb.set_trace()
Like @enrico.bacis has mentioned pp
can be used for pretty printing while using pdb.
(Pdb) pp your_var