python Programming Glossary: settrace
What cool hacks can be done using sys.settrace? http://stackoverflow.com/questions/1692866/what-cool-hacks-can-be-done-using-sys-settrace cool hacks can be done using sys.settrace I love being able to modify the arguments the get sent to a.. to modify the arguments the get sent to a function using settrace like import sys def trace_func frame event arg value frame.f_locals.. a value def f a print a if __name__ __main__ sys.settrace trace_func for i in range 0 5 f i And this will print 1 1 3..
Decorator to log function execution line by line http://stackoverflow.com/questions/19227636/decorator-to-log-function-execution-line-by-line func def _wrapper old_trace_function sys.gettrace sys.settrace logging_tracer try result func except raise else return result.. result func except raise else return result finally sys.settrace old_trace_function return _wrapper Unfortunately this prints.. in the right direction. This is a bit hackey sys.gettrace settrace are rather promenently documented as CPython implementation..
pydev breakpoints not working http://stackoverflow.com/questions/9486871/pydev-breakpoints-not-working ' frame.f_lineno ' tEvent ' event return trace_func sys.settrace trace_func If you still can't figure it out please post more.. that's not figured out you can do import pydevd pydevd.settrace on the place where you'd put the breakpoint that way you'd have..
|