PY
py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import sys
def tracer(frame, event, arg):
print("> Event: ", event,
" @", frame.f_lineno,
" Cmd: ", frame.f_locals.get('cmd'),
" Arg: ", arg,
# frame.f_locals, # show messy encoding too
sep="")
if event == 'line':
try:
if frame.f_locals['cmd'] == 'delete':
print("> deleting...\n")
del frame.f_trace
elif frame.f_locals['cmd'] == 'setNone':
print("> Wiping...\n")
frame.f_trace = None
except:
# suppress events having {'input':'delete', ...}
# print("Other 'line' event:", frame.f_locals)
pass
return None # or function() I think?
return tracer
def traceMe(cmd):
# Each of these causes 3 extra events doing encoding;
# Comment @4-9 to suppress or add frame.f_locals to see.
Enter to Rename, Shift+Enter to Preview
OUTPUT
Run