how to extract source code from code objects ?
Michele Simionato
mis6 at pitt.edu
Thu Jan 2 11:14:52 EST 2003
I can compile a string in a code object:
>>> code_object=compile('x=1','<string>','exec')
now the code_object.co_code attribute contains the bytecode corresponding
to the statement x=1:
>>> code_object.co_code
'\x7f\x00\x00\x7f\x01\x00d\x00\x00Z\x00\x00d\x01\x00S'
Is there a way to have back the source code, i.e. the string 'x=1'
instead of the bytecode ?
TIA,
--
Michele Simionato - Dept. of Physics and Astronomy
210 Allen Hall Pittsburgh PA 15260 U.S.A.
Phone: 001-412-624-9041 Fax: 001-412-624-9163
Home-page: http://www.phyast.pitt.edu/~micheles/
More information about the Python-list
mailing list