If it won't be simple, it simply won't be. [source code] by Miki Tebeka, CEO, 353Solutions

Wednesday, May 10, 2006

"Hard" breakpoints in Python

Sometimes, when debugging, you want a to stop at abreakpoint no matter what.
Use the following code:

from pdb import set_trace

def buggy_function():
pass
pass
set_trace() # Break here
pass
pass

if __name__ == "__main__":
buggy_function()

When you run the script with python (not with pdb), set_trace will cause the program to stop at this line and pdb console will show.

BTW: You can do the same trick on MSVC if you write __asm int 3
Post a Comment

Blog Archive