Skip to content

Debugging Python code

December 20, 2009

Reading through the third chapter of my bazillion page Python book, I came across a discussion of debuggers.  I’m used to the way Matlab works when debugging – putting little stop buttons on certain lines, and stepping through the code if I need to.  Since my code always has bugs in it, I thought learning about debuggers would be important.  I was surprised to see that the first two recommended ‘debugging’ methods in my book were:  (1) Do nothing!  Just read the error statements, and go to that line in your code and fix it.  (2) Print statements – this lets you print out a message or a variable value, generally enough to tell you what you need to know.  These first two are all I’ve ever used before, and seemed to be fine for me.  Also, the author of the book says those are the only ones he uses.  And he wrote the bazillion page book, so he must know what he’s talking about.  I will stick with these two, but mention the other three just for interest’s sake:  (3) IDE GUI debuggers like IDLE, (4) pdb, a command line debugger that is contained in Python’s standard library, and (5) more specific debugging option such as winpdb.

This information can be found on page 67 of Learning Python.

So, once again, the KISS (keep it simple, stupid) method prevails.  I love it.

No comments yet

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: