Injecting code into a function

George Sakkis gsakkis at rutgers.edu
Tue Apr 26 02:03:57 EDT 2005


> Oh, I overlooked this. Then the solution becomes simple:
>
>    sys._getframe().f_trace
>
> Test:
>
> >>> an = Analyzer()
> >>> sys.settrace(an.trace_returns)
> >>> sys._getframe().f_trace
> <bound method Analyzer.trace_returns of <__main__.Analyzer instance
at
> 0x010015D0>>

Does this work for you non-interactively ? I tried running it from a
script or importing it from a module but it returns None. Very
strange...

George




More information about the Python-list mailing list