PySnooper lets you do the same, except instead of carefully crafting the right print lines, you just add one decorator line to the function you're interested in. You'll get a play-by-play log of your function, including which lines ran and when, and exactly when local variables were changed.
A very well done description of decorators in python. Go in depth about how functions are first class objects, scope, self-modifying code, and how everything works. programming languages documentation tutorial
3722 links, including 192 private