using breakpoints in a normal interactive session

dan.gass at gmail.com dan.gass at gmail.com
Wed Feb 22 14:22:00 EST 2006


Is there a way to temporarily halt execution of a script (without using
a debugger) and have it put you in an interactive session where you
have access to the locals?  And possibly resume?  For example:

>>> def a():
...   x = 1
...   magic_breakpoint()
...   y = 1
...   print "got here"
...
>>> a()
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
  File "<stdin>", line 3, in a
  File "<stdin>", line 2, in magic_breakpoint
>>> x
1
>>> y
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
NameError: name 'y' is not defined
>>> magic_resume()
got here
>>> x
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
NameError: name 'x' is not defined




More information about the Python-list mailing list