[Tutor] parsing pyc files

Alan Gauld alan.gauld at btinternet.com
Tue Mar 23 10:27:48 CET 2010

"Jojo Mwebaze" <jojo.mwebaze at gmail.com> wrote

> How is possible to trace the all method calls, object instantiations,
> variables used in running an experiment dynamically,  without putting 
> print
> - or log statements in my code?  - some sort of provenance!

There are several debuggers for Python including the pdb
module in the standard library and the "graphical" one in IDLE.

> I would like to create a tool that can look into pyc files to find
> classes/methods that was executed without looking the the source code. Is
> this possible in python.

I don't know of a debugger for the bytecode.
There are tools to generate it for a specific function so you can
see what it looks like, but I don't know of any that can dynamically
monitor execution.

The profiler can also tell you what was executed after the fact.

This is an unusual request can I ask why you need to do that?

Alan Gauld
Author of the Learn to Program web site

More information about the Tutor mailing list