breakpoint() Enter debugger

Last updated: 2026-09-22

breakpoint() Enter debugger

breakpoint() drops into the debugger (pdb by default); customizable via PYTHONBREAKPOINT or sys.breakpointhook().

CategoryBuilt-in Functions
KindBuilt-in Function
Python Version3.7+

📝 Syntax

breakpoint(*args, **kws)

⚙️ Parameters

args OptionalVariable positional arguments passed through to the hook.
kwargs OptionalVariable keyword arguments passed through to the hook.

Returns:None; the actual behavior is delegated to sys.breakpointhook().

▶ Example

Edit the code, press Run, and see the result in the output panel:

Output:

breakpoint skipped
after
More case studies coming soon — check back later.

❓ FAQ

QHow do I keep breakpoint() from activating in production?
ASet the environment variable PYTHONBREAKPOINT=0, or run sys.breakpointhook = lambda *a, **k: None in your code; after that breakpoint() becomes a no-op.
QWhat debugger does breakpoint() enter by default?
AIt enters pdb (Python's built-in debugger). The program pauses at the call site and shows a (Pdb) prompt where you can inspect/modify variables and step through the code.
QWhat is the difference between debugging with breakpoint() vs print()?
Aprint() can only print output and you have to insert/remove it manually; breakpoint() drops you into a real debugger where you can inspect all local variables, evaluate arbitrary expressions, and step through — then delete one line when done.
QCan I customize the breakpoint behavior?
AYes. Point sys.breakpointhook at a custom hook (e.g. ipdb.set_trace), or specify one via the PYTHONBREAKPOINT environment variable, for instance to use an alternative to pdb.
Web-Tutorial.com

Web-Tutorial Tech Team

A team of developers maintaining programming tutorials. Each tutorial is written and reviewed by developers with expertise in that field. We work to keep our content accurate and reliable — if you spot an issue, please let us know.

100%

🙏 帮我们做得更好

我们是刚上线的编程教程站,几个人的小团队,精力有限。页面虽经检查,难免还有疏漏——链接失效、排版错乱、内容有误、语言生硬……

如果您发现了,麻烦告诉我们,我们会在收到反馈后第一时间进行修复,再次感谢您的光临 🙏