Let's improve our debugging skills

print()

print('I am here!!!!')

f-string for debugging

https://fstring.help/

In [1]: fruit = 'banana'
   ...: f'{fruit=}'
Out[1]: "fruit='banana'"

The Python Debugger

import pdb; pdb.set_trace()
breakpoint()

Python 3.7

The Python Debugger

Commands:

q (quit)

n (next)

p (print)

c (continue)

s (step into)

a (arguments)

ipdb

import ipdb; ipdb.set_trace()
pip install ipdb

It uses IPython

pdbr = pdb + rich + ipython

Rich is a Python library for rich text and beautiful formatting in the terminal.


The Rich API makes it easy to add color and style to terminal output. Rich can also render pretty tables, progress bars, markdown, syntax highlighted source code, tracebacks, and more — out of the box.

pdbr = pdb + rich + ipython

import pdbr; pdbr.set_trace()
pip install pdbr
export PYTHONBREAKPOINT="pdbr.set_trace"
breakpoint()

Let's improve your debug skills

By Beatriz Uezu

Let's improve your debug skills

  • 25