Getting a module's byte code, how?

Mark Nenadov mark at freelance-developer.com
Wed Feb 2 17:06:22 EST 2005


On Wed, 02 Feb 2005 23:03:17 +0100, Irmen de Jong wrote:

> What would be the best way, if any, to obtain
> the bytecode for a given loaded module?
> 
> I can get the source:
> import inspect
> import os
> src = inspect.getsource(os)
> 
> but there is no ispect.getbytecode()  ;-)
> 
> --Irmen

The inspect API documentation says that code objects have "co_code", which
is a string of raw compiled bytecode.

Hope that helps!

- -
Mark Nenadov
Python Byte Solutions
http://www.pythonbyte.com/



More information about the Python-list mailing list