Entry
Executing binaries...?
Jul 5th, 2000 10:02
Nathan Wallace, Hans Nowak, Snippet 234, M.-A. Lemburg
"""
Packages: miscellaneous;core_python
"""
"""
> Is there any way to execute python binaries with something like
> execfile (giving it a special environment as a dict)? The only way I
> can thing of is using execfile that imports another file (which is
> compiled)... Is there any other way?
"""
def execpyc(filename,globals=None,locals=None):
""" Execute a byte compiled file filename in globals, locals
"""
import marshal
f = open(filename,'rb')
f.read(8) # skip header (id check omitted)
code = marshal.load(f)
exec code in globals,locals