summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrew M. Kuchling <amk@amk.ca>2006-07-28 12:45:55 (GMT)
committerAndrew M. Kuchling <amk@amk.ca>2006-07-28 12:45:55 (GMT)
commit1d69a7013f83faf1547ac8f4fca769a1a42de3e9 (patch)
tree28de5ca32e7943648ced76096a95e45e5e5434b7
parentbd468103e0f8649a600db0d02395fc600a4bd124 (diff)
downloadcpython-1d69a7013f83faf1547ac8f4fca769a1a42de3e9.zip
cpython-1d69a7013f83faf1547ac8f4fca769a1a42de3e9.tar.gz
cpython-1d69a7013f83faf1547ac8f4fca769a1a42de3e9.tar.bz2
Don't overwrite built-in name; add some blank lines for readability
-rw-r--r--Doc/lib/libshelve.tex4
1 files changed, 3 insertions, 1 deletions
diff --git a/Doc/lib/libshelve.tex b/Doc/lib/libshelve.tex
index 8bd204e..6ca3576 100644
--- a/Doc/lib/libshelve.tex
+++ b/Doc/lib/libshelve.tex
@@ -143,15 +143,17 @@ data = d[key] # retrieve a COPY of data at key (raise KeyError if no
del d[key] # delete data stored at key (raises KeyError
# if no such key)
flag = d.has_key(key) # true if the key exists
-list = d.keys() # a list of all existing keys (slow!)
+klist = d.keys() # a list of all existing keys (slow!)
# as d was opened WITHOUT writeback=True, beware:
d['xx'] = range(4) # this works as expected, but...
d['xx'].append(5) # *this doesn't!* -- d['xx'] is STILL range(4)!!!
+
# having opened d without writeback=True, you need to code carefully:
temp = d['xx'] # extracts the copy
temp.append(5) # mutates the copy
d['xx'] = temp # stores the copy right back, to persist it
+
# or, d=shelve.open(filename,writeback=True) would let you just code
# d['xx'].append(5) and have it work as expected, BUT it would also
# consume more memory and make the d.close() operation slower.