Code on Github

Bienvenue 환영합니다 Bienvenido - ようこそ Welcome 歡迎光臨

friendly helps users understand what caused a given exception in their Python program, and how to fix it.

There exists many Python projects whose primary goal is to supplement the information given by Python traceback to make them more useful for advanced programmers. To my knowledge, of all those projects, friendly is the only one designed with beginners in mind.

To be more specific, while friendly can be useful for advanced programmers, it strives to present the information in a way that is easily understood by beginners and/or by users who would like to get information about traceback in their own language. friendly can give more detailed information as to where an exception occurred, what a given exception means and why it might have occurred (sometimes adding suggestions as to how to fix it.)

Even though friendly can be used on its own with a specially designed console, a better option might be to use it together with GUI-based editors/IDE including JupyterLab and Jupyter notebooks. I explain how to do so later. For now, I’ll just show one quick example.

A quick look

Consider the following program:

# example.py
def get_last(seq):
    last_index = len(seq)
    return seq[last_index]

print(get_last([1, 2, 3]))

First, here is what happens when I use Python to run this program.

Python IndexError example

Not exactly the most helpful information for beginners …

Here’s the corresponding version with full explanation from friendly, making use of Rich to produce a colourful output.

friendly IndexError example in English

One unique feature of friendly is that all the information it provides can be translated into another language; currently, only English (by default) and French are available.

friendly IndexError in French

Keep reading if you want to find out more.

To do

I sometimes add notes about planned changes or additions to the documentation in various sections. Any such note is listed below as a visible reminder, mostly for my own purpose.

Todo

Ensure that friendly can be integrated within Thonny and used to supplement Thonny’s own “Assistant”.

(The original entry is located in C:\Users\andre\github\friendly-traceback-docs\docs\source\install_thonny.rst, line 53.)

Todo

Determine if there would be interest in integrating friendly with ptpython. This might perhaps be done by monkey-patching _handle_exception or by having ptpython’s developer enable custom sys.excepthook.

(The original entry is located in C:\Users\andre\github\friendly-traceback-docs\docs\source\other_repl.rst, line 18.)