-1

When my python code crashes, I'd like to be able to pause, quickly type some python code that would fix the error, then resume execution. Is it possible to run it in some type of pdb mode that sets a trace on crash before the stack is cleared, or wrap code in a try/except mode that automatically goes back to the crashed line or something? All I need is to quickly add a line that would fix the error, then resume the call stack from the errored line. Seems similar to an ipynb for each line, but ideally it would be line by line and automatic for a .py file.

John Targaryen
  • 1,109
  • 1
  • 13
  • 29

2 Answers2

1

Run-time interaction depends on your particular IDE; it is not a language feature. Python supplies the exception handling (try-except, since you haven't looked it up yet) you see in the documentation, but does not define how an IDE might provide interactive code editing.

Prune
  • 76,765
  • 14
  • 60
  • 81
0

You can throw it in a try/except block, however that might be difficult to stop and resume a script like that. Better to write in the REPL for that behavior I think.