How can I retrieve a value from a function after it crashes? E.g. how would I find the value of a
after the function completes/crashes.
>>> def a_is_3():
... a=3
... print 'a='+str(a)
...
>>> a_is_3()
a=3
>>> a
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name 'a' is not defined
My real case includes massive numpy arrays created and passed around through dozens of modules. The arrays are still taking up memory after the code errors, but I can't access them.
Is there a way to retrieve what the variables were at the moment when the function crashed? I want to avoid having to add debug code and re-run the lengthy execution to capture the variables. It seems like a particularly useful trick for troubleshooting.