Python breakpoint()

Python breakpoint() builtin function lets us to enter debugger at this function call site.

In this tutorial, we will learn about the syntax of Python breakpoint() function, and learn how to use this function with the help of examples.


The syntax of breakpoint() function is

breakpoint(*args, **kws)




In this example, we will write a Python program to find the largest element of a list. After initializing the list, and before finding the largest, we will call breakpoint() function as shown in the following program.

Python Program

myList = [24, 0, 8, 6]
largest = max(myList)

Run this program, and you should enter into Python debugger as shown below.

Python breakpoint - Python debugger

Now, we can query variables that are instantiated till this point in the program. Let us query myList. Python debugger shall echo the value of myList and wait for another command.

Python breakpoint - Python debugger

Now, let us query for the variable largest. Since, the variable is not yet initialized in the program, Python debugger might raise an error.

Python breakpoint - Python debugger

Thus, we can debug our application using breakpoint() function.


In this Python Tutorial, we have learnt the syntax of Python breakpoint() builtin function, and also learned how to use this function, with the help of Python example programs.