Python breakpoint() Example

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 – breakpoint()

The syntax of breakpoint() function is:

breakpoint(*args, **kws)

Example 1: breakpoint() function

In this example, we will call breakpoint() function at some point in our python program and see what happens.

Python Program

a = 2
b = 3

if(a+b == 5):
	print('sum is 5')
Run this program


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\<module>()
-> print('sum is 5')
(Pdb) +a
(Pdb) +b
(Pdb) a+b
(Pdb) +a+b


In this tutorial of Python Examples, we learned how to use breakpoint() function to debug your Python application.