Instrumenting Python Code

Viewed 3612

I want to instrument every if condition encountered inside a python function automatically. For example if my code hits:

if x > 2:
    #do something

I want to record/ print "x > 2" to the console.

I found this tool "equip" https://github.com/neuroo/equip/ but it only instuments at function boundaries. I think I need to be able to instrument at the bytecode instruction level to get those conditionals out.

Currently, I have to manually stdout/append after every if condition like

if x > 2:    
    list.append("x>2")
1 Answers
Related