Getting source code from interpreter-defined function

Michele Simionato mis6 at pitt.edu
Fri Apr 11 15:40:03 EDT 2003


"POYEN OP Olivier (DCL)" <Olivier.POYEN at clf-dexia.com> wrote in message news:<mailman.1050055156.23007.python-list at python.org>...
> Hi all,
> 
> I'm playing with inspect module, which, BTW, is great for finding useful =
> info on saved object, written object.
> With inspect, I can get source code from a function.
> 
> Is there anyway I could do the same with "alive" object, without having =
> to wrap the whole python interpreter and create tmpfile for writing =
> session ? (an "alive" object would be an object defined at the =
> interpreter prompt)
> 
 --

This thread maybe of interest to you:

http://groups.google.com/groups?hl=en&lr=&ie=UTF-8&threadm=2259b0e2.0301030725.93d18c9%40posting.google.com&rnum=1&prev=/groups%3Fhl%3Den%26lr%3D%26ie%3DISO-8859-1%26q%3Dsimionato%2Bdecompyle%26meta%3D

In short, you cannot extract the source from live objects; you can
decompile the bytecode, though, by using the decompyle module.


                             Michele




More information about the Python-list mailing list