You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
For some time I have used this in my personal debug tools:
importipdbclassDecontext(object):
""" Makes a context manager also act as decorator """def__init__(self, context_manager):
self._cm=context_managerdef__enter__(self):
returnself._cm.__enter__()
def__exit__(self, *args, **kwds):
returnself._cm.__exit__(*args, **kwds)
def__call__(self, func):
defwrapper(*args, **kwds):
withself:
returnfunc(*args, **kwds)
returnwrapperpm=Decontext(ipdb.launch_ipdb_on_exception())
It allows me to do this:
from mydebugtools import pm
@pm
def main():
# whatever
And ipdb is triggered on an exception at any level below that function in the call stack.
This is kind of a silly convenience thing, maybe just personal preference, but I thought others might benefit from seeing it. Would it be reasonable to add this functionality to ipdb? If so, would it be sensible to use this (not named pm), or is there a better way?
The text was updated successfully, but these errors were encountered:
For some time I have used this in my personal debug tools:
It allows me to do this:
And ipdb is triggered on an exception at any level below that function in the call stack.
This is kind of a silly convenience thing, maybe just personal preference, but I thought others might benefit from seeing it. Would it be reasonable to add this functionality to ipdb? If so, would it be sensible to use this (not named
pm
), or is there a better way?The text was updated successfully, but these errors were encountered: