DEV Community

qing
qing

Posted on

3x Faster Debugging

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

When debugging Python code, it's common to use the pdb module to set breakpoints and step through your code. However, since Python 3.7, there's a more convenient way to do this. Say goodbye to import pdb; pdb.set_trace() and hello to the built-in breakpoint() function.

The breakpoint() function is a shortcut that allows you to set a breakpoint in your code without having to import the pdb module. When called, it will drop you into a debugger at that point in your code, allowing you to inspect variables, step through code, and more.

Here's an example:


python

---

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

---

### 🛠️ Recommended Tool

If you found this useful, check out **[Content Creator Ultimate Bundle (Save 33%)](https://gumroad.com)** — $29.99 and designed for developers like you.

*Get instant access to our best-selling AI Dev Boost, HTML Landing Page Templates, AI Prompts for Developers, and Python Automation Scripts Pack, perfect for content creators and marketers looking to elevate their game. This bundle is a must-have for anyone looking to create stunning content, build high-converting landing pages, and drive real results. With these tools, you'll be able to create engaging content, build beautiful landing pages, and boost your online presence.*

---
喜欢这篇文章?关注获取更多Python自动化内容!
Enter fullscreen mode Exit fullscreen mode

Top comments (0)