Message143789
If you write 'How to debug Python code' rather than just "How to use pdb", I would start with the use of print statements and binary search. Have short sections on using trace and profile. Very useful would be a list of error messages and possible un-obvious to beginners but common causes. The following example comes up regularly on python-list.
TypeError: 'int' object is not callable
Look in the previous line to see what you called. If it is a builtin name, perhaps you re-assigned the name to something else. Example:
list = 3
<many lines later>
list(1,2,3)
Traceback (most recent call last):
File "<pyshell#7>", line 1, in <module>
list(1,2,3)
TypeError: 'int' object is not callable
Another one we see occasionally ("Is module x broken?") is something like: user runs script.py
import random
x = random.random()
Traceback...
NameError: name 'random.random' is not defined
Solution: user has a file random.py in the same directory |
|
Date |
User |
Action |
Args |
2011-09-09 18:57:43 | terry.reedy | set | recipients:
+ terry.reedy, ezio.melotti, eric.araujo |
2011-09-09 18:57:43 | terry.reedy | set | messageid: <1315594663.92.0.0878989522122.issue12913@psf.upfronthosting.co.za> |
2011-09-09 18:57:43 | terry.reedy | link | issue12913 messages |
2011-09-09 18:57:42 | terry.reedy | create | |
|