Skip to content

Instantly share code, notes, and snippets.

@ramuta
Created August 23, 2016 19:47
Show Gist options
  • Save ramuta/d8a26a7cc35ccbfd8838047236014001 to your computer and use it in GitHub Desktop.
Save ramuta/d8a26a7cc35ccbfd8838047236014001 to your computer and use it in GitHub Desktop.
Python pickle example
# -*- 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