DEV Community

qing
qing

Posted on

Quick Tip: Use `breakpoint()` instead of `import pdb; pdb.set_trace()` (2026)

Quick Tip: Use breakpoint() instead of import pdb; pdb.set_trace()

When debugging Python code, it's common to insert a line like import pdb; pdb.set_trace() to drop into a debugger. However, starting from Python 3.7, there's a more convenient way to achieve the same result: the built-in breakpoint() function.

breakpoint() is a shortcut that calls pdb.set_trace() under the hood, but with less boilerplate code. You can simply insert breakpoint() wherever you want to pause execution and inspect variables, making your debugging workflow more efficient.

Here's an example:


python
def my_function(x):
    breakpoint()  # pause execution here
    print(x

---

*Follow me on Dev.to for daily Python tips and quick guides!*

---

*💡 Related: **Content Creator Ultimate Bundle (Save 33%)** — $29.99*

---

## 🔗 Recommended Resources

- [Python Crash Course](https://www.amazon.com/Python-Crash-Course-2nd-Edition/dp/1593279280?tag=automoney-20) — *3-10%*

*Note: Some links are affiliate links. Using them supports this blog at no extra cost to you.*
Enter fullscreen mode Exit fullscreen mode

Top comments (0)