February 2006
Intermediate to advanced
648 pages
14h 53m
English
The shelve module provides support for persistent objects using a special “shelf” object. This object behaves like a dictionary except that all the objects it contains are stored on disk using a database such as dbm or gdbm. A shelf is created using the shelve.open() function.
open(filename [, flag=’c’ [, protocol [, writeback]]])Opens a shelf file. If the file doesn’t exist, it’s created. filename should be the database filename and should not include a suffix. flag has the same meaning as described in the chapter introduction and is one of ‘r’, ‘w’, ‘c’, or ‘n’. If the database file doesn’t exist, it is created. protocol specifies the protocol used to pickle objects stored in the database. It has the same meaning as described in the ...