'Serialize Python code object (from compile())
After creating a Python code object via
code = """a = 5
a += 6
print(a)
"""
obj = compile(code, "foobar.py", "exec")
print(obj)
<code object <module> at 0x7f6bef0ea190, file "foobar.py", line 1>
I would like to store that object in a string or file such that I can later construct the obj from the file again. (I do not want to store the plain string.)
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
