⊕
⊖
Contents
Python – breakpoint()
pythondebug() function drops you into the debugger at the call site. Specifically, it calls sys.breakpointhook(), passing args and kws straight through.
In this tutorial, we shall learn how to use breakpoint(), to debug your Python application in the console.
Syntax of breakpoint()
The syntax of breakpoint() function is:
breakpoint(*args, **kws)
Examples
1. Set break point in if statement
In this example, we will call breakpoint() function at some point in our python program and see what happens.
Output
The system enters Python debugging mode at the print() statement and you can check the variable values in console as shown below.
C:\workspace\python>python example.py
> c:\workspace\python\example.py(6)<module>()
-> print('sum is 5')
(Pdb) +a
2
(Pdb) +b
3
(Pdb) a+b
(Pdb) +a+b
5
(Pdb)
Summary
In this tutorial of Python Examples, we learned how to use breakpoint() function to debug your Python application.