This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: No simple example for pickle
Type: enhancement Stage:
Components: Documentation Versions:
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: georg.brandl, kjohnson
Priority: normal Keywords:

Created on 2006-03-01 16:49 by kjohnson, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Messages (2)
msg54746 - (view) Author: Kent Johnson (kjohnson) * Date: 2006-03-01 16:49
The docs for pickle lack a simple example of typical
usage. The Example page has only an advanced example. I
suggest something like this be added to the Usage or
Examples page:

Here is a simple example that shows how to use pickle
to save and restore a dictionary:
 >>> import pickle
 >>> data = dict(a=1, b=2, c=[3,4,5], d='cheese')
 >>> f=open('data.pickle', 'wb')
 >>> pickle.dump(data, f)
 >>> f.close()
 >>>
 >>> f=open('data.pickle', 'rb')
 >>> data2=pickle.load(f)
 >>> f.close()
 >>> data2
{'a': 1, 'c': [3, 4, 5], 'b': 2, 'd': 'cheese'}


Kent
msg54747 - (view) Author: Georg Brandl (georg.brandl) * (Python committer) Date: 2006-07-28 18:10
Logged In: YES 
user_id=849994

A simple example was added by Andrew in rev. 50903.
History
Date User Action Args
2022-04-11 14:56:15adminsetgithub: 42960
2006-03-01 16:49:38kjohnsoncreate