Gatsby Logo

Using ipdb with breakpoint in python

2020-04-15

In your home folder you should have the following directory:

~$ .ipython/profile_default/startup/

If you make a .py file there it will be run every time that ipython is started.

import os
import ipdb
os.environ['PYTHONBREAKPOINT'] = 'ipdb.set_trace'

This will allow you to use breakpoint() in your scripts and it will trigger the ipdb debugger.

> /home/rick/dev/chemcurator_django/chemreg/compound/validators.py(110)validate_smiles()
    109         breakpoint()
--> 110         ps.ParseSmiles(smiles, partial=False)
    111     except ps.ValenceError:

ipdb> type your commands here!

The details can be found in the docs

Have a nice day! - Rick Debbout