extract function copies the local variables from the current function frame into the existing Jupyter session. If the Python code crashes, you can enter the debugger with the
%debug magic and then use the
extract function to copy the variables from the function frame into the Jupyter session. The variables can now be properly inspected, e.g., plotted.
The original URI above contains more details how to use this post-mortem debugging.
"""Copies the variables of the caller up to iPython. Useful for debugging. .. code-block:: python def f(): x = 'hello world' extract() f() # raises an error print(x) # prints 'hello world' """ = = . , , = , , = , , = , , = , , = , , = . # Magic call to make the updates to f_locals 'stick'. # More info: https://pydev.blogspot.co.uk/2014/02/changing-locals-of-frame-frameflocals.html =