[Tutor] Debugging skills

Mats Wichmann mats at wichmann.us
Mon Jan 15 11:16:23 EST 2024


On 1/15/24 02:27, dn via Tutor wrote:
> On 15/01/24 17:16, dn via Tutor wrote:
>> On 6/01/24 02:56, Mats Wichmann wrote:
>>> 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...
> 
> Re-reading recent post - when copy came [back] from the reflector, I 
> wondered about LLMs.
> 
> If you come across someone who lands in just such a problem, where 
> his/her mental model is considerably at-odds with the interpreter; it 
> would be very interesting to see if/how an LLM helps them through.
> 
> Alternately, if you can recall such circumstance, I'll be keen to try to 
> reproduce and to experiment...

Well, I can name one very simple one:  if you've programmed only in, for 
example C, your mental model is arrays are pre-allocated (and hopefully 
you remember the fixed size so you don't go out of bounds), so you might 
try to use a Python list the same way - the syntax looks similar, after 
all...

data = []
for i in range(5):
     data[i] = i

IndexError: list assignment index out of range

Wait, what?

Obviously you then quickly learn, so I'm not sure this was a 
particularly useful example, but the brain wants to follow patterns it 
knows.





More information about the Tutor mailing list