[Python-Dev] Python interpreter crash. (original) (raw)

Guido van Rossum guido@python.org
Tue, 12 Mar 2002 21:15:03 -0500


I was searching for a way to construct a new module from it's file's compiled bytecode (just read() the "*.pyc" file),

import marshal, imp f = open("foo.pyc") f.seek(8) code = marshal.load(f) f.close() foo = imp.new_module("foo") exec code in foo.dict

--Guido van Rossum (home page: http://www.python.org/~guido/)