Sometimes you want to know what functions are being called - for example when you're trying to figure out how a complex package works. Fortunately, Python makes this pretty easy - the sys
package contains a settrace
method that allows you to do just that. Unfortunately, it's a bit eager, and doesn't work particularly well in a notebook environment without a bit of tweaking. That's because settrace
will tell you all the functions that are called - even those that are just to do with executing code from the notebook itself.
So... I wrote a function that seems to handle all that faff pretty well. Here it is: