Debugging Python Code

09 Nov ยท by Tim Kamanin ยท 1 min read

Debugging python code is extremelly simple and powerfull. Just use ipdb for this purposes:

pip install ipdb

Then open up your code and in the place where you need code to stop insert this:

import pdb; pdb.set_trace()

When you refresh the browser or execute a .py file, code execution will stop in this place and controll will be passed to a command line. There you can do whatever you want, like inspect local variables with


inspect global variables with


or execute any other functions. To continue just type


That's a real power! Compare it with PHP's pre, print or var_dump approaches.

Want to get more ๐Ÿ”ฅ tips like this one?

Subscribe to get notified about new dev tutorials