Warning

This project is being split into 3 separate projects:

  • friendly_traceback,

  • friendly, and

  • friendly_idle.

The documentation does not reflect this change.

If you are a end-user, just install friendly until further notice.

history() and back()

Earlier, I mentioned that I recommend that beginners use an editor instead of a REPL for writing Python code. The main reason is that it is easier to correct mistakes, and does not require to rewrite entire lines of code. At the same time, I recommend the use of friendly’s console to “ask questions” when an exception is raised.

Consider the following situation, with some code that takes a long time to execute:

_images/history1.png

Suppose I want to have more details about where the exception was raised.

_images/history2.png

I made a mistake; no problem, friendly told me how to fix it.

_images/history3.png

Unfortunately, this is not the exception I was looking for.

Instead of having to run the entire program once again, friendly has preserved a history of the exceptions seen so far, and allows me to discard them one by one, starting with the last one.

_images/history4.png

The only exception left is the one of interest.

_images/history5.png

I found the cause of the error: I wrote a string '13' instead of an integer.