Created
March 8, 2012 09:49
-
-
Save tokibito/2000021 to your computer and use it in GitHub Desktop.
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 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