1 \section{Built-in Module
\sectcode{dbm
}}
4 The
\code{dbm
} module provides an interface to the
{\UNIX}
5 \code{(n)dbm
} library. Dbm objects behave like mappings
6 (dictionaries), except that keys and values are always strings.
7 Printing a dbm object doesn't print the keys and values, and the
8 \code{items()
} and
\code{values()
} methods are not supported.
10 See also the
\code{gdbm
} module, which provides a similar interface
11 using the GNU GDBM library.
14 The module defines the following constant and functions:
16 \renewcommand{\indexsubitem}{(in module dbm)
}
17 \begin{excdesc
}{error
}
18 Raised on dbm-specific errors, such as I/O errors.
\code{KeyError
} is
19 raised for general mapping errors like specifying an incorrect key.
22 \begin{funcdesc
}{open
}{filename\,
\optional{flag\,
\optional{mode
}}}
23 Open a dbm database and return a dbm object. The
\var{filename
}
24 argument is the name of the database file (without the
\file{.dir
} or
25 \file{.pag
} extensions).
27 The optional
\var{flag
} argument can be
28 \code{'r'
} (to open an existing database for reading only --- default),
29 \code{'w'
} (to open an existing database for reading and writing),
30 \code{'c'
} (which creates the database if it doesn't exist), or
31 \code{'n'
} (which always creates a new empty database).
33 The optional
\var{mode
} argument is the
\UNIX{} mode of the file, used
34 only when the database has to be created. It defaults to octal