Advertisement
Guest User

Marshaling

a guest
Apr 20th, 2018
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.35 KB | None | 0 0
  1. # from original example
  2. with open('simple.py', 'r') as f:
  3.     code = f.read()
  4. exec(code)
  5. # compile and run again
  6. a = compile(code, "simple_compiled_this_file_not_created", "exec")
  7. exec(a)
  8. # marshal and unmarshal
  9. import marshal
  10. f = open("./marshalfoo.bin", "wb")
  11. marshal.dump(a,f)
  12. f.close()
  13. b = marshal.load(open("./marshalfoo.bin", "rb"))
  14. exec(b)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement