CHAPTER 13 ■ SERIALIZING PYTHON OBJECTS
208
Loading Data from a Pickle File
Now switch to your second Python shell–that is, not the one where you created the entry dictionary
(see Listing 13-5).
Listing 13-5. Loading a Data Structure from a File
>>> shell (1)
2
>>> entry (2)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name 'entry' is not defined
>>> import pickle
>>> with open('entry.pickle', 'rb') as f: (3)
... entry = pickle.load(f) (4)
...
>>> entry (5)
{'comments_link': None,
'internal_id': b'\xDE\xD5\xB4\xF8',
'title': 'Dive into history, 2009 edition',
'tags': ('diveintopython', 'docbook', 'html'),
'article_link':
'http://diveintomark.org/archives/2009/03/27/«
dive-into-history-2009-edition', ...