@@ -137,37 +137,38 @@ then prints out the contents of the database::
137
137
The individual submodules are described in the following sections.
138
138
139
139
140
- :mod: `dbm.gnu ` --- GNU's reinterpretation of dbm
141
- ------------------------------------------------
140
+ :mod: `dbm.gnu ` --- GNU database manager
141
+ ---------------------------------------
142
142
143
143
.. module :: dbm.gnu
144
144
:platform: Unix
145
- :synopsis: GNU's reinterpretation of dbm.
145
+ :synopsis: GNU database manager
146
146
147
147
**Source code: ** :source: `Lib/dbm/gnu.py `
148
148
149
149
--------------
150
150
151
- This module is quite similar to the :mod: `dbm ` module, but uses the GNU library
152
- `` gdbm `` instead to provide some additional functionality. Please note that the
153
- file formats created by :mod: ` dbm.gnu ` and :mod: ` dbm.ndbm ` are incompatible .
151
+ The :mod: `dbm.gnu ` module provides an interface to the :abbr: ` GDBM ( GNU dbm ) `
152
+ library, similar to the :mod: ` dbm.ndbm ` module, but with additional
153
+ functionality like crash tolerance .
154
154
155
- The :mod: `dbm.gnu ` module provides an interface to the GNU DBM library.
156
- ``dbm.gnu.gdbm `` objects behave like mappings (dictionaries), except that keys and
157
- values are always converted to bytes before storing. Printing a ``gdbm ``
158
- object doesn't print the
159
- keys and values, and the :meth: `items ` and :meth: `values ` methods are not
160
- supported.
155
+ :class: `!gdbm ` objects behave similar to :term: `mappings <mapping> `,
156
+ except that keys and values are always converted to :class: `bytes ` before storing,
157
+ and the :meth: `!items ` and :meth: `!values ` methods are not supported.
158
+
159
+ .. note ::
160
+ The file formats created by :mod: `dbm.gnu ` and :mod: `dbm.ndbm ` are
161
+ incompatible and can not be used interchangeably.
161
162
162
163
.. exception :: error
163
164
164
165
Raised on :mod: `dbm.gnu `-specific errors, such as I/O errors. :exc: `KeyError ` is
165
166
raised for general mapping errors like specifying an incorrect key.
166
167
167
168
168
- .. function :: open(filename[ , flag[ , mode]] )
169
+ .. function :: open(filename, flag="r" , mode=0o666, / )
169
170
170
- Open a `` gdbm `` database and return a :class: `gdbm ` object. The *filename *
171
+ Open a GDBM database and return a :class: `! gdbm ` object. The *filename *
171
172
argument is the name of the database file.
172
173
173
174
The optional *flag * argument can be:
@@ -196,14 +197,14 @@ supported.
196
197
| ``'u' `` | Do not lock database. |
197
198
+---------+--------------------------------------------+
198
199
199
- Not all flags are valid for all versions of `` gdbm `` . The module constant
200
+ Not all flags are valid for all versions of GDBM . The module constant
200
201
:const: `open_flags ` is a string of supported flag characters. The exception
201
202
:exc: `error ` is raised if an invalid flag is specified.
202
203
203
204
The optional *mode * argument is the Unix mode of the file, used only when the
204
205
database has to be created. It defaults to octal ``0o666 ``.
205
206
206
- In addition to the dictionary-like methods, `` gdbm ` ` objects have the
207
+ In addition to the dictionary-like methods, :class: ` gdbm ` objects have the
207
208
following methods:
208
209
209
210
.. versionchanged :: 3.11
@@ -212,7 +213,7 @@ supported.
212
213
.. method :: gdbm.firstkey()
213
214
214
215
It's possible to loop over every key in the database using this method and the
215
- :meth: `nextkey ` method. The traversal is ordered by `` gdbm `` 's internal
216
+ :meth: `nextkey ` method. The traversal is ordered by GDBM 's internal
216
217
hash values, and won't be sorted by the key values. This method returns
217
218
the starting key.
218
219
@@ -230,7 +231,7 @@ supported.
230
231
.. method :: gdbm.reorganize()
231
232
232
233
If you have carried out a lot of deletions and would like to shrink the space
233
- used by the `` gdbm `` file, this routine will reorganize the database. `` gdbm ` `
234
+ used by the GDBM file, this routine will reorganize the database. :class: ` ! gdbm `
234
235
objects will not shorten the length of a database file except by using this
235
236
reorganization; otherwise, deleted file space will be kept and reused as new
236
237
(key, value) pairs are added.
@@ -242,11 +243,11 @@ supported.
242
243
243
244
.. method :: gdbm.close()
244
245
245
- Close the `` gdbm `` database.
246
+ Close the GDBM database.
246
247
247
248
.. method :: gdbm.clear()
248
249
249
- Remove all items from the `` gdbm `` database.
250
+ Remove all items from the GDBM database.
250
251
251
252
.. versionadded :: 3.13
252
253
0 commit comments