breakpoint(): pause code execution and open an interactive debugger

breakpoint() to stop execution of program

We can stop execution of the script at a point and check the value ( or result ) of different process till that point. From this stop point we can again continue execution of the rest of the processes.

Let us see this example.
a=5
print(a)
breakpoint()
a="Welcome"
print(a)
After printing value of a as 5, our process will stop. It will prompt to enter value. We can enter c to further continue the program. We can quit from this point by entering q

This is the final output.
5
--Return--
> <ipython-input-11-bf9737819636>(3)<module>()->None
-> breakpoint()
(Pdb) c
Welcome

with condition

We can use if else and based on condition use the brakpoint()
x=13
if x >10:
    print(x)
    breakpoint() # stop execution 
else:
    print('Value is fine ')
Using inside class
class Animal():

     #class attributes
    species='carnivores'

     #instance attributes
    def __init__(self1,name1,age,weight):
        self1.name= name1
        breakpoint()
        self1.age=age
        self1.weight=weight
        self1.height=5  #instance attribute

 #instantiate the Animal  class
tiger=Animal("Ronald",5,15)  # tiger is an object of Animal class
breakpoint()
 # access the instance attributes
print("{} is {} years old animal".format( tiger.name, tiger.age))
All Built in Functions in Python chr() ord()
Subhendu Mohapatra — author at plus2net
Subhendu Mohapatra

Author

🎥 Join me live on YouTube

Passionate about coding and teaching, I publish practical tutorials on PHP, Python, JavaScript, SQL, and web development. My goal is to make learning simple, engaging, and project‑oriented with real examples and source code.



Subscribe to our YouTube Channel here



plus2net.com







Python Video Tutorials
Python SQLite Video Tutorials
Python MySQL Video Tutorials
Python Tkinter Video Tutorials
We use cookies to improve your browsing experience. . Learn more
HTML MySQL PHP JavaScript ASP Photoshop Articles Contact us
©2000-2025   plus2net.com   All rights reserved worldwide Privacy Policy Disclaimer