Next: grp Prev: UNIX ONLY Up: UNIX ONLY Top: Top

5.1. Built-in Module dbm

Dbm provides python programs with an interface to the unix ndbm database library. Dbm objects are of the mapping type, so they can be handled just like objects of the built-in dictionary type, except that keys and values are always strings, and printing a dbm object doesn't print the keys and values.

The module defines the following constant and functions:

error -- exception of module dbm
Raised on dbm-specific errors, such as I/O errors. KeyError is raised for general mapping errors like specifying an incorrect key.
open (filename, rwmode, filemode) -- function of module dbm
Open a dbm database and return a mapping object. filename is the name of the database file (without the .dir or .pag extensions), rwmode is 'r', 'w' or 'rw' as for open, and filemode is the unix mode of the file, used only when the database has to be created.