5

Only Python: Going back in history

 3 years ago
source link: https://aroberge.blogspot.com/2021/03/going-back-in-history.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

Going back in history

Imagine that you wish to run a program that takes a long time to run. Just in case somethings goes wrong, you decide to use friendly-traceback (soon to be renamed...) in interactive mode to run it.  This turns out to be a good decision:

history1.png
Time to explore what might be the problem, and where exactly things might have gone wrong.
history2.png
Ooops ... a silly typo. Easy enough to correct:
history3.png
Unfortunately, that did not work: Friendly-traceback, like all Python programs designed to handle exceptions, only capture the last one.
This has happened to me so many times; granted, it was always with short programs so that I could easily recreate the original exception. However, I can only imagine how frustrating it might be for beginners encountering this situation.

A solution

Fortunately, you are using the latest version of Friendly-traceback, the one that records exceptions that were captured, and allows you to discard the last one recorded (rinse, and repeat as often as needed), thus going back in history.
history4.png
Now that we are set, we can explore further to determine what might have gone wrong.
history5.png

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK