sys.settrace and Bdb.trace_dispatch can trace events. But the "line" event is triggered before the execution of the line. I'm trying to get information exactly after the line being executed, but not before the next line's execution. Now I can record the lines and info like filenames to mimic after the line behaviour by actually tracing before the next line. But there're too many burdens especially when multiple modules exist, and the last line can not be traced. So is there a way to trace a line after it's executed in Python? Continue reading...