2๐
The third one. You have to enforce some commit rules. For example, run a serie of tests before a commit, etc. This way, developpers have a simple way to check if a pdb break remain. If someone commit a set_trace, he has to bake a cake for the rest of the team.
This works fine in my company ๐
edit: you may present this method to your boss as CDD (Cake Driven Developpement)
1๐
The best option would be to have an extensive test suite, and to run the tests before pushing to production. Extraneous pdb
breakpoints will prevent the tests from passing.
If you canโt do that, then option 2 is the best: write a utility to break into the debugger, and make it sensitive to the state of the settings. You still have to solve the problem of how to be sure people use the wrapper rather than a raw pdb
call though.
- [Django]-MySQL query performance cliff on large table with two IN statements
- [Django]-Setting value of a hidden field in Django form
0๐
Ideally, You shouldnโt be including debugging code in the first place. You can instead use a wrapper that sets breakpoints and invokes the main program for debugging, so that the main program contains no actual set_trace()
calls at all.
# foo.py
print "hello"
print "goodbye"
and
#debug_foo.py
import pdb
def run_foo():
execfile('foo.py')
db = pdb.Pdb()
db.set_break("foo.py", 2)
db.run("run_foo()")
Example:
[~]$ python foo.py hello goodbye [~]$ python foo.py > <string>(1)<module>() (Pdb) continue hello > /home/dbornside/foo.py(1)<module>() -> print "goodbye" (Pdb) continue goodbye [~]$
- [Django]-Django admin list_display foreign key id without join
- [Django]-Struggling to get django_comments to work with Django REST Framework
- [Django]-Django v2+ regex for custom path converter to handle csv
- [Django]-Custom django-admin commands โ AttributeError: 'Command' object has no attribute 'stdout'