I'm in the process of learning how a large (356-file), convoluted Python program is set up. Besides manually reading through and parsing the code, are there any good methods for following program flow?
There are two methods which I think would be useful:
- Something similar to Bash's "set -x"
- Something that displays which file outputs each line of output
Are there any methods to do the above, or any other ways that you have found useful?
I don't know if this is actually a good idea, but since I actually wrote a hook to display the file and line before each line of output to stdout, I might as well give it to you…
Just save that as a module, and after you
import
it, every chunk of stdout will be prefixed with file and line number.Of course this will get pretty ugly if:
stdout.write
directly, orprint
magic comma in 2.x, orend=''
in 3.x).But all the tricky deep-Python-magic bits are there; you can build on top of it pretty easily.