Jupyter Lab and notebook history callback (recover cell’s)— Quick Tip
Probably any of us deleted a cell in Jupyter and wanted to recall it. Sometimes simple Edit/Undo works and there are times that this is not enough.
In the case that we changed some variables and deleted the whole cell after it and continued to work further, the Undo function for me is not an option as in this case you would redone everything to that point change was made.
In the above picture I created a dummy_variable and changed it from 3 to 5. Then the 1st cell was deleted. To recall 10 last cells, the simple _ih[-10:] function needs to be called in a loop.
# look back what was dummy_variable at start
for history in _ih[-10:]:
print(history)
Thank you for reading this short tip and trick and consider subscribing.
Thanks!