Search code examples
pythondebuggingbreakpoints

Is there a way of using breakpoints in python?


I am just wondering if there is a way to add breakpoints in IDLE so that I can stop at a point in my script and write other lines in the idle shell for testing. If not, is there other software that can do this?


Solution

  • you can add the line

    import pdb; pdb.set_trace()
    

    anywhere in your code, when reached it will drop you into a debug shell. so useful i have an emacs shortcut to add the snippet.

    you may also want to look at ipdb, and use

    import ipdb; ipdb.set_trace()
    

    instead