Author terry.reedy
Recipients eric.araujo, ezio.melotti, terry.reedy
Date 2011-09-09.18:57:42
SpamBayes Score 1.9391e-11
Marked as misclassified No
Message-id <>
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>
Traceback (most recent call last):
  File "<pyshell#7>", line 1, in <module>
TypeError: 'int' object is not callable 

Another one we see occasionally ("Is module x broken?") is something like: user runs

import random
x = random.random()
NameError: name 'random.random' is not defined

Solution: user has a file in the same directory
Date User Action Args
2011-09-09 18:57:43terry.reedysetrecipients: + terry.reedy, ezio.melotti, eric.araujo
2011-09-09 18:57:43terry.reedysetmessageid: <>
2011-09-09 18:57:43terry.reedylinkissue12913 messages
2011-09-09 18:57:42terry.reedycreate