O'Reilly logo

Python: Essential Reference, Third Edition by David Beazley

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

shelve

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required