Hacker News new | ask | show | jobs
by rowanseymour 1057 days ago
Since Python 3.7

  import pdb
  pdb.set_trace()
can be written as just

  breakpoint()
4 comments

That's not entirely true, because `breakpoint` is a more general hook, `pdb.set_trace` is just its default behaviour.

This is, if anything, better. Because that way you can e.g. replace stray `breakpoint()` calls by warnings rather than break production :D

I was told that at my job, but my fingers are so used to type `pdb` and emacs template-replacing it that I can't change.
Configure Emacs to template-replace it with breakpoint()
And this also works with Debugpy so you can actually use a proper debugger and not pdb which is frankly terrible.
Thanks for the tip! :)