Created
August 23, 2016 19:47
-
-
Save ramuta/d8a26a7cc35ccbfd8838047236014001 to your computer and use it in GitHub Desktop.
Python pickle example
This file contains hidden or 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
# -*- coding: utf-8 -*- | |
import pickle | |
class SomeModel(): | |
pass | |
a = SomeModel() | |
a.name = "Matej" | |
with open('filename.pickle', 'wb') as handle: | |
pickle.dump(a, handle) | |
with open('filename.pickle', 'rb') as handle: | |
b = pickle.load(handle) | |
print a == b | |
print a.name | |
print b.name |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment