summaryrefslogtreecommitdiffstats
path: root/Doc/includes
diff options
context:
space:
mode:
authorAlexandre Vassalotti <alexandre@peadrop.com>2008-10-24 01:32:40 (GMT)
committerAlexandre Vassalotti <alexandre@peadrop.com>2008-10-24 01:32:40 (GMT)
commitd03928614f20e29d3f9a934e2c85bc09c8df3ae8 (patch)
tree3ed7f0f075369177f739a6267d30276490f2dd54 /Doc/includes
parent62073e0b516fd153c9414ded4cd908bcd78ca669 (diff)
downloadcpython-d03928614f20e29d3f9a934e2c85bc09c8df3ae8.zip
cpython-d03928614f20e29d3f9a934e2c85bc09c8df3ae8.tar.gz
cpython-d03928614f20e29d3f9a934e2c85bc09c8df3ae8.tar.bz2
More improvements to pickle's documentation.
Add "Restricting Globals" section. Remove useless 'verbose' flag in the example dbpickle.py.
Diffstat (limited to 'Doc/includes')
-rw-r--r--Doc/includes/dbpickle.py14
1 files changed, 6 insertions, 8 deletions
diff --git a/Doc/includes/dbpickle.py b/Doc/includes/dbpickle.py
index d2eee6c..1158744 100644
--- a/Doc/includes/dbpickle.py
+++ b/Doc/includes/dbpickle.py
@@ -46,7 +46,7 @@ class DBUnpickler(pickle.Unpickler):
raise pickle.UnpicklingError("unsupported persistent object")
-def main(verbose=True):
+def main():
import io, pprint
# Initialize and populate our database.
@@ -68,20 +68,18 @@ def main(verbose=True):
file = io.BytesIO()
DBPickler(file).dump(memos)
- if verbose:
- print("Records to be pickled:")
- pprint.pprint(memos)
+ print("Pickled records:")
+ pprint.pprint(memos)
# Update a record, just for good measure.
cursor.execute("UPDATE memos SET task='learn italian' WHERE key=1")
- # Load the reports from the pickle data stream.
+ # Load the records from the pickle data stream.
file.seek(0)
memos = DBUnpickler(file, conn).load()
- if verbose:
- print("Unpickled records:")
- pprint.pprint(memos)
+ print("Unpickled records:")
+ pprint.pprint(memos)
if __name__ == '__main__':