@@ -58,41 +58,33 @@ the Oracle Berkeley DB.
5858
5959.. function :: open(file, flag='r', mode=0o666)
6060
61- Open the database file * file * and return a corresponding object.
61+ Open a database and return the corresponding database object.
6262
63- If the database file already exists, the :func: `whichdb ` function is used to
64- determine its type and the appropriate module is used; if it does not exist,
65- the first module listed above that can be imported is used.
63+ :param file:
64+ The database file to open.
6665
67- The optional *flag * argument can be:
66+ If the database file already exists, the :func: `whichdb ` function is used to
67+ determine its type and the appropriate module is used; if it does not exist,
68+ the first submodule listed above that can be imported is used.
69+ :type file: :term: `path-like object `
6870
69- .. csv-table ::
70- :header: "Value", "Meaning"
71+ :param str flag:
72+ * ``'r' `` (default), |flag_r |
73+ * ``'w' ``, |flag_w |
74+ * ``'c' ``, |flag_c |
75+ * ``'n' ``, |flag_n |
7176
72- ``'r' `` (default), |flag_r |
73- ``'w' ``, |flag_w |
74- ``'c' ``, |flag_c |
75- ``'n' ``, |flag_n |
76-
77- The optional *mode * argument is the Unix mode of the file, used only when the
78- database has to be created. It defaults to octal ``0o666 `` (and will be
79- modified by the prevailing umask).
77+ :param int mode:
78+ The Unix file access mode of the file (default: octal ``0o666 ``),
79+ used only when the database has to be created.
8080
8181 .. versionchanged :: 3.11
8282 *file * accepts a :term: `path-like object `.
8383
84-
85- The object returned by :func: `open ` supports the same basic functionality as a
84+ The object returned by :func: `~dbm.open ` supports the same basic functionality as a
8685:class: `dict `; keys and their corresponding values can be stored, retrieved, and
8786deleted, and the :keyword: `in ` operator and the :meth: `!keys ` method are
88- available, as well as :meth: `!get ` and :meth: `!setdefault `.
89-
90- .. versionchanged :: 3.2
91- :meth: `!get ` and :meth: `!setdefault ` are now available in all database modules.
92-
93- .. versionchanged :: 3.8
94- Deleting a key from a read-only database raises database module specific error
95- instead of :exc: `KeyError `.
87+ available, as well as :meth: `!get ` and :meth: `!setdefault ` methods.
9688
9789Key and values are always stored as :class: `bytes `. This means that when
9890strings are used they are implicitly converted to the default encoding before
@@ -101,9 +93,17 @@ being stored.
10193These objects also support being used in a :keyword: `with ` statement, which
10294will automatically close them when done.
10395
96+ .. versionchanged :: 3.2
97+ :meth: `!get ` and :meth: `!setdefault ` methods are now available for all
98+ :mod: `dbm ` backends.
99+
104100.. versionchanged :: 3.4
105101 Added native support for the context management protocol to the objects
106- returned by :func: `.open `.
102+ returned by :func: `~dbm.open `.
103+
104+ .. versionchanged :: 3.8
105+ Deleting a key from a read-only database raises a database module specific exception
106+ instead of :exc: `KeyError `.
107107
108108The following example records some hostnames and a corresponding title, and
109109then prints out the contents of the database::
0 commit comments