So heres a couple of small tips:
Tracing Python Method Calls
I wanted to just trace an indented stack trace on the fly, as a debugging aid. This is what I devised:
pytrace_rx = re.compile(".*3c/phases/phase-.+/")
def pytrace(frame, event, arg):
"""
this is for the -V flag (caps V)
prints each python stack frame as it is opened.
(slow)
"""
if event == "call":
full_path = frame.f_code.co_filename
if pytrace_rx.match(full_path):
fn = full_path.split("/").pop()
sz = frame.f_code.co_stacksize
level = -1
tmp_frame = frame
while tmp_frame != None:
level = level + 1
tmp_frame = tmp_frame.f_back
pad = level * " "
print(pad + "> " + fn + ": " + \
frame.f_code.co_name)
sys.settrace(pytrace) # turn on tracing
Cool huh!
Drawing Parse Trees in LaTeX with QTree
\usepackage{qtree}
...
\Tree[.EXPR
[.EXPR
[.EXPR
[.number [.1 ] ]
]
[.OPER
[.+ ]
]
[.number
[.2 ]
]
]
[.OPER
[.- ]
]
[.number
[.3 ]
]
]
Gives you:

Sweet!
1 comments:
QTree, coooooool!
Post a Comment