Search code examples
pythonbreakpointsconditional-breakpoint

How to use breakpoint in python without using IDE features


It will great help if you can explain with code example or any useful resource.


Solution

  • you can use the in-built pdb library.

    import pdb 
    a = 10
    pdb.set_trace()
    print(a)
    

    So what it would basically do is, stop the program after line 2 is executed. and from there you would have command line access to the code with is execute above the set_trace() is added.

    You can read more about it here.