Source

features/pep-420 / Doc / libdbm.tex

The branch 'legacy-trunk' does not exist.
\section{Built-in Module \sectcode{dbm}}
\bimodindex{dbm}

The \code{dbm} module provides an interface to the {\UNIX}
\code{(n)dbm} library.  Dbm objects behave like mappings
(dictionaries), except that keys and values are always strings.
Printing a dbm object doesn't print the keys and values, and the
\code{items()} and \code{values()} methods are not supported.

See also the \code{gdbm} module, which provides a similar interface
using the GNU GDBM library.
\bimodindex{gdbm}

The module defines the following constant and functions:

\renewcommand{\indexsubitem}{(in module dbm)}
\begin{excdesc}{error}
Raised on dbm-specific errors, such as I/O errors. \code{KeyError} is
raised for general mapping errors like specifying an incorrect key.
\end{excdesc}

\begin{funcdesc}{open}{filename\, \optional{flag\, \optional{mode}}}
Open a dbm database and return a dbm object.  The \var{filename}
argument is the name of the database file (without the \file{.dir} or
\file{.pag} extensions).

The optional \var{flag} argument can be
\code{'r'} (to open an existing database for reading only --- default),
\code{'w'} (to open an existing database for reading and writing),
\code{'c'} (which creates the database if it doesn't exist), or
\code{'n'} (which always creates a new empty database).

The optional \var{mode} argument is the \UNIX{} mode of the file, used
only when the database has to be created.  It defaults to octal
\code{0666}.
\end{funcdesc}
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.