Created
April 9, 2016 09:41
-
-
Save PetteriAimonen/8a05e7b908183251f55ea43d118b49b2 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
>>> class foobar: pass | |
... | |
>>> A = foobar() | |
>>> B = foobar() | |
>>> A.b = B | |
>>> B.a = A | |
>>> pickle.dumps(A) | |
"(i__main__\nfoobar\np0\n(dp1\nS'b'\np2\n(i__main__\nfoobar\np3\n(dp4\nS'a'\np5\ng0\nsbsb." | |
>>> newA = pickle.loads(pickle.dumps(A)) | |
>>> newA.b | |
<__main__.foobar instance at 0x7f82262cb0e0> | |
>>> newA.b.a.b | |
<__main__.foobar instance at 0x7f82262cb0e0> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment