Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Python Write Better Python Buggy Logs The Python Debugger

I would think that it is still better to put import pdb at the top of the script...

I would think that it is still better to put import pdb at the top of the script so that in the situation that you forgot to remove it other developers could easily see that the pdb was used and they could then remove it. Otherwise they would have to search through all the code for it or run a find and replace.

3 Answers

Kenneth Love
STAFF
Kenneth Love
Treehouse Guest Teacher

Sure. But since you're usually going to remove it right after you get through checking something, having the import and the use side-by-side makes the removal a lot faster and easier.

Johnathan,

I've also done the following for debugging parts throughout a long group project.

At the top put: debug = 1

Down in the code: if debug: import pdb

I've also had different levels of a debug defined by larger integers. That way you don't have to change the code, except for the debug on the top, and the debugging is turned on and off either by a boolean or by integer value and module.

Ron

import pdb; pdb.set_trace()

THIS ONE WORKS FOR ME

Thanks KENNETH for teach me these things