Is there a way to use the setTrace () function in a script that does not have method definitions? i.e.
for i in range(1, 100):
print i
def traceit(frame, event, arg):
if event == "line":
lineno = frame.f_lineno
print "line", lineno
return traceit
sys.settrace(traceit)
so I would like the trace function to be called on every iteration / line of code executed in a loop. I did this with scripts that previously had method definitions, but I'm not sure how to make it work on this instance.
source
share