Skip to content

Instantly share code, notes, and snippets.

@tokibito
Created March 8, 2012 09:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tokibito/2000021 to your computer and use it in GitHub Desktop.
Save tokibito/2000021 to your computer and use it in GitHub Desktop.
# coding: utf-8
import cPickle as pickle
class Spam(object):
def __init__(self, name, value):
self.name = name
self.value = value
def __repr__(self):
return "<%s: name=%s, value=%s>" % (
self.__class__.__name__,
self.name,
self.value)
def main():
obj = Spam('Furukawa', 'bucho')
print "original: %s" % obj
s = pickle.dumps(obj)
print "======================="
print s
print "======================="
obj_2 = pickle.loads(s)
print "unpickled: %s" % obj_2
if __name__ == '__main__':
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment