Advertisement
rfmonk

pickle_load_from_file_1.py

Jan 29th, 2014
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.52 KB | None | 0 0
  1. #1/usr/bin/env python
  2.  
  3. # this is from The Python
  4. # Standard Library by example
  5. # ISBN13: 9780321767349
  6.  
  7. try:
  8.     import cPickle as pickle
  9. except:
  10.     import pickle
  11. import pprint
  12. from StringIO import StringIO
  13. import sys
  14. from pickle_dump_to_file_1 import SimpleObject
  15.  
  16. filename = sys.argv[1]
  17.  
  18. with open(filename, 'rb') as in_s:
  19.     # Read the data
  20.     while True:
  21.         try:
  22.             o = pickle.load(in_s)
  23.         except EOFError:
  24.             break
  25.         else:
  26.             print 'READ: %s (%s)' % (o.name, o.name_backwards)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement