Quite some colleagues use my name to raise an error. It is a trick I learned them :-)
There are a large number of debugging tips and tricks. import pdb
;
print
statements; a full-blown IDE with an interactive debugger; logging;
etc.
Often the simplest and most useful thing to check is to first verify that you’re looking in the right place at all. Why? Well, you might be working on the right python file, but are you really sure that your web app isn’t using a previously installed package instead of your checked out developer version, for instance?
Or you work on some method, but another class overrides the method you’re debugging.
In cases like this I often add a print(reinout)
statement somewhere in the
function. That’s not a typo. It definitively should not be
print("reinout")
. The latter only prints reinout
, the first prints:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name 'reinout' is not defined
Much easier to spot. Makes it obvious that at least you’re looking in the right spot!
My name is Reinout van Rees and I work a lot with Python (programming language) and Django (website framework). I live in The Netherlands and I'm happily married to Annie van Rees-Kooiman.
Most of my website content is in my weblog. You can keep up to date by subscribing to the automatic feeds (for instance with Google reader):