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

gdbm

The gdbm module provides an interface to the GNU DBM library.

open(filename [, flag=’r’ [, mode]])

Opens a gdbm database with filename filename. Appending ‘f’ to the flag opens the database in fast mode. In this mode, altered data is not automatically written to disk after every change, resulting in better performance. If this flag is used, the sync() method should be used to force unwritten data to be written to disk on program termination.

A gdbm object, d, behaves like a dictionary, as described in the section “Introduction” earlier in this chapter, but it also supports the following methods:

MethodDescription
d.firstkey()Returns the starting key in the database.
d.nextkey(key)Returns the key that follows key in a traversal of the database. ...

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