[Tutor] Debugging skills
dn
PythonList at DancesWithMice.info
Sun Jan 14 23:16:35 EST 2024
On 6/01/24 02:56, Mats Wichmann wrote:
> On 1/4/24 14:58, dn via Tutor wrote:
>
>>>> Interestingly the paper book version of my tutorial has a chapter on
>>>> debugging. However, I've never got round to adding that chapter
>>>> to the online version. I probably should...
>>>
>>> That would be cool.
>
> while we're nattering on a whole range of sort-of-debugging topics,
> here's something I've occasionally wondered about, when a beginner has
> written something that makes sense only to them, not to the Python
> interpreter. Regexes are confusing, so there are several websites (see
> for example regex101.com) where you can enter your "code" (regex) and as
> it's interpreted, will show you an explanation in words in a separate
> pane. Does anyone know if there's a similar thing for Python code?
> "This is what you wrote actually means to the interpreter". Ones I know
> about (like at Programiz, w3schools, online-python) don't attempt the
> explanation part. It's not something that's likely to be useful for
> very many cases, but I could see where in the beginning there might be
> some benefit...
It's a lot easier to build such 'checkers' when working with a small and
bounded system, than with something as broad as Python.
Am thinking that the best tool to diagnose when a trainee's mental-model
diverges from Python's way of working, is the interpreter. Work has been
invested in recent versions to improve err.msgs/diagnostics. Of course,
this will never be perfect, and it is a bug-bear of learners of all
languages that the diagnosis may be incorrect, and thus a red-herring.
The concern is valid, and particularly in a self-teach/remote-learner
situation where asking someone for help may be problematic.
Reprising earlier conversation, I fear that the attempt to go too far,
too fast, will lead to, or certainly more-frequently evidence this problem.
My solution (in other topics) is to show multiple examples of (correct)
working-code and discuss how each works, in order to create and
reinforce the requisite mental-model. Then ask the trainees to solve a
(very) similar problem - for which many have the wit to copy a suitable
example, and edit from there. Seems to work!
As previously-mentioned, and echoed by @Roel, PythonTutor does go some
way to illustrating what's happening under-the-hood. No, pdb is not so
good (IMHO) and thus even less-so in a training environment. PyCharm's
debugger does a reasonable job, by stepping-through and showing values
as they change in a dashboard-like manner - but it doesn't draw the
'pretty pictures' per PythonTutor or Thonny.
--
Regards,
=dn
More information about the Tutor
mailing list