Wednesday, December 09, 2020

IPython and Friendly-traceback

 This is a quick update on the status of Friendly-traceback. As of today, it works with the IPython console, and works even better in a JupyterLab environment.  

First, a comparison with using it in the new Windows terminal making use of Rich for syntax highlighting, which is something that has been working for quite a while now.



Next, is the same example in an IPython console, running in a Windows terminal.



I've tried to use Rich to do syntax colouring with the IPython console ... but the result is really disappointing. 








Finally, here's what it looks like in the JupyterLab environment.



Right now, it is not possible to select a different theme for syntax highlighting; this will have to wait until later.


To find out more about Friendly-traceback (excluding this new IPython experimental support), please consult the documentation.




Saturday, October 24, 2020

Friendly-traceback: work in progress

 It's been almost two months since my last blog post and I feel guilty of not having taken the time to write more regularly.  I should really tell you about how fantastic Will McGugan's Rich is, and how I have customized it for my projects. I should also tell you how Sylvain Desodt's DidYouMeanPython has been influencing Friendly-traceback latest developments. Also worthy of note is how Alex Hall's FutureCoder project is incorporating so many neat tools that it feels like a real honour that he has incorporated Friendly-traceback in it.

Alas, while I have been busy making many changes and addition to the code, the documentation is hopelessly behind and no longer gives a correct picture of what Friendly-traceback is now capable of.

So much to do, so little time. So, I will just end with a picture, and go back to coding, with a promise of writing more ... soon I hope.



Monday, August 10, 2020

Rich + Friendly-traceback: first look

 After a couple of hours of work, I have been able to use Rich to add colour to Friendly-traceback. Rich is a fantastic project, which has already gotten a fair bit of attention and deserves even more.

The following is just a preview of things to come; it is just a quick proof of concept.


Friendly-traceback has 10 so-called verbosity settings, one of which is simply to show the normal Python traceback.

There is, of course, much, much more to come ...

Update: more work in progress





Tuesday, August 04, 2020

Identifying misleading type hints

Yesterday on Twitter:


For beginners, unintentional type hints can be really confusing.  No SyntaxError, no traceback to guide the beginners ... Still, could Friendly-traceback help?



I've already mentioned how Friendly-traceback could be used by Thonny, and how it could also be used with Mu.  What about IDLE?



Yes, it can.  And what if it is typos and not type hints that are causing problems?




Note: This is freshly written code. The documentation really needs to be updated to reflect the most recent changes.

Wednesday, July 29, 2020

HackInScience: friendly Python learning

A short while ago I discovered HackInScience, a fantastic site for learning Python by doing exercises. It currently includes 68 programming exercises, with increasing level of difficulty.
I learned about it via an issue filed for Friendly-traceback: yes, HackInScience does use Friendly-traceback to provide feedback to users when their code raises Python exceptions.  These real-life experiences have resulted in additional cases being covered by Friendly-traceback: there are now 128 different test cases, each providing more helpful explanation as to what went wrong than that offered by Python. Python versions 3.6 to 3.9 inclusively are supported.

Previously, I thought I would get feedback about missing cases from teachers or beginners using either Mu or Thonny - both of which can make use of Friendly-traceback. However, this has not been the case yet, and this makes me extremely grateful for the feedback received from HackInScience.

While Friendly-traceback can provide feedback in either English or French [1], HackInScience only uses the English version - this, in spite of the fact that it was created by four French programmers.  I suspect that it is only a matter of time until they make a French version of their site.

One excellent additional feature provided by HackInScience is the addition of formatting (including some colour) in the output provided by Friendly-traceback.



The additional cases provided by Julien Palard from HackInScience have motivated me to clear out the accumulated backlog of test cases I had identified on my own. Now, there is only one (new) issue: enabling coloured output from Friendly-traceback's console.

Please, feel free to interrupt my work on this new issue by submitting new cases that are not covered by Friendly-traceback! ;-)

[1] Anyone interested in providing translations in other languages is definitely welcome!