Skip to content

Instantly share code, notes, and snippets.

@deadbits
Created April 12, 2012 22:30
Show Gist options
  • Save deadbits/2371466 to your computer and use it in GitHub Desktop.
Save deadbits/2371466 to your computer and use it in GitHub Desktop.
and again...
import marshal
script = """
print 'hello'
"""
code = compile(script, "<script>", "exec")
data = marshal.dumps(code)
# intermediate format
print type(data), len(data)
print "-"*50
print repr(data)
print "-"*50
exec marshal.loads(data)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment