Help me with this code PLEASE

bob gailer bgailer at gmail.com
Wed Nov 6 00:15:56 CET 2013


There is also the shelve module.

It uses pickle to marshal a Python object, then stores it in a file 
under a key.

Sample code from the module documentation:

import shelve

d = shelve.open(filename) # open -- file may get suffix added by 
low-level library

d[key] = data   # store data at key (overwrites old data if using an 
existing key)
data = d[key]   # retrieve a COPY of data at key (raise KeyError if no 
such key)
del d[key]      # delete data stored at key (raises KeyError if no such key)
flag = key in d        # true if the key exists
klist = list(d.keys()) # a list of all existing keys (slow!)


-- 
Bob Gailer
919-636-4239
Chapel Hill NC




More information about the Python-list mailing list