[Tutor] Debugging skills
ThreeBlindQuarks
threesomequarks at proton.me
Tue Jan 2 17:30:20 EST 2024
After some recent discussions here, I think the best gift for some learners is learning debugging skills.
As an example Mr. Rosenberg probably could benefit from writing small amounts of code then stopping and testing the results up to that point to see if it was what was expected. You can use Python very interactively including various methods of cutting and pasting or a line or region at a time if using RSTUDIO to run it.
So it can be useful to people to run some code, pause and check things like what is the current content of a variable, what "type" python thinks it is or if it is a composite object like a class, examine some of the contents. I am not talking about a formal debugger, just fairly basic stuff.
When you encounter an error message, you definitely should not proceed with more code until it has been dealt with as some errors make the rest of your code be treated as nonsense.
And, certainly, there are debuggers you can learn and use but mostly there is no need.
If you do things like this and then still hit a wall, you can then ask a question here more intelligently and using the minimal amount of code that reproduces the error.
Ages ago, I used to work and teach with programs written on punch cards and handed in and received back hours or days later. Those were primitive times where you felt you had to write a whole progra before submitting it. That is not the case with Python and incremental work is often a decent approach as long as you have a good editor or setup and know how to make sure to write modular code that can be tested and debugged in small chunks.
The other thing to keep remembering is that when programming in a language, ONLY the rules for that language apply. Sometimes people forget that python uses indentation quite precisely and although extra parentheses and other kinds of brackets may seem harmless, sometimes they really aren't. Because of the indentation issues, unlike some other languages, copying code from one place to another, or just moving it within a program generally causes problems as it may not be aligned as expected.
And some symbols simply do not mean the same thing as in some other language such as curly braces generally are reserved for a set or dictionary and not for grouping.
I think people have a tendency to jump ahead and do more challenging things before they have mastered the basics. I know I often do but I also know enough to back away and examine my environment when things are not working or even switch to other methods I know already.
My guess is some people are using a resource, such as an online list of programming exercises that are not really designed as a teaching experience where each section extends what has already been learned. They may be better off with some more formal course such as some of the free course on coursera or perhaps paid versions that do better grading and offer a certificate:
https://www.coursera.org/search?query=python&
Of course, if you are someone like me who mainly learns languages these days as a sort of hobby, ...
More information about the Tutor
mailing list