[issue38054] enhance pdb.set_trace() to run when the specified condition is true
Alexander Ulyanov
report at bugs.python.org
Tue Sep 10 09:09:54 EDT 2019
Alexander Ulyanov <alex.ulnv at gmail.com> added the comment:
Perhaps it's a matter of preference. I found it convenient, since passing in a boolean expression allows me to get rid of extra if-blocks thus reducing lines of code and increasing debugging speed. I wanted to share my idea with the community - but please feel free to close the issue if you find it trivial.
############## SAMPLE USE CASE ##############
import pdb
def square(i):
pdb.set_trace(trigger=not isinstance(i, (float, int)))
print(i**2)
# debug: hunting for TypeError
a = 2
square(a) # will not execute set_trace()
b = None
square(b) # will execute set_trace()
----------
_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue38054>
_______________________________________
More information about the Python-bugs-list
mailing list