import signal # could be cool to have a configurable prompt def _pdb_sigint(signum, frame): breakpoint() signal.signal(signal.SIGINT, _pdb_sigint) # use with `import pdb_sigint`