Terry J. Reedy <[email protected]> added the comment:
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
----------
nosy: +terry.reedy
_______________________________________
Python tracker <[email protected]>
<http://bugs.python.org/issue12913>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com