Can Python print out the line by line flow (or order) of a run?
问题 I have a Python assignment where I need to describe the order in which Python ran the program by identifying line numbers. This is to help us understand the try/except and errors. I'm pretty sure I've achieved this through inspection, but I wanted to know if Python has the ability to print out the flow by line numbers so I may check my work. If Python does not have this built in, is there a way in which I could do this? I am working with Python 2.7. 回答1: Try the trace module: Example: test.py