extracting code objects from .pyc

Christos TZOTZIOY Georgiou tzot at sil-tec.gr
Sat May 29 21:11:59 EDT 2004


On Sat, 29 May 2004 14:27:39 -0400, rumours say that Phil Frost
<indigo at bitglue.com> might have written:

>clarification: I'm looking for something that will give me a PyObject
>of the code flavor that can be passed to something like
>PyImport_ExecCodeModule, not a reconstruction of the source code.

py_compile.py in your Python standard library has somewhere the
following lines that create a .pyc file:

    fc = open(cfile, 'wb')
    fc.write('\0\0\0\0')
    wr_long(fc, timestamp)
    marshal.dump(codeobject, fc)

HTH.
-- 
TZOTZIOY, I speak England very best,
"I have a cunning plan, m'lord" --Sean Bean as Odysseus/Ulysses



More information about the Python-list mailing list