Skip to Content
Python: Essential Reference, Third Edition
book

Python: Essential Reference, Third Edition

by David Beazley
February 2006
Intermediate to advanced content levelIntermediate to advanced
648 pages
14h 53m
English
Sams
Content preview from Python: Essential Reference, Third Edition

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. ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Python: Essential Reference

Python: Essential Reference

David M. Beazley

Publisher Resources

ISBN: 0672328623Purchase book