Search This Blog

Sunday, January 16, 2011

PYTHON - enable debugging

Writing a program in python is challenging when something goes extremely wrong. Fortunately, Python debugger is at hand.

Insert this line in your code where you suspect a bug to be hidden:

import pdb; pdb.set_trace() 
-> this causes the script to stop and a debug console pops out.

l -> to see a short listing of code of the place you're currently executing
dir(object_name) -> to display object's methods & fields


No comments:

Post a Comment

If you like this post, please leave a comment :)