Executing binaries...?
Michael P. Reilly
arcege at shore.net
Mon Oct 18 12:46:12 EDT 1999
M.-A. Lemburg <mal at lemburg.com> wrote:
: "Magnus L. Hetland" wrote:
:>
:> 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
:
Is there anything wrong with the standard function?
execfile(filename, [globals[, locals]])
<URL: http://www.python.org/doc/current/lib/built-in-func.html>
-Arcege
More information about the Python-list
mailing list