@@ -124,36 +124,43 @@ will automatically close them when done.
124124
125125.. _dbm-key-value-types :
126126
127- Key and Value Types
127+ Key and value types
128128-------------------
129129
130130The accepted types for keys and values vary by backend. Keys and values are
131131handled identically:
132132
133- * **Traditional backends **:
133+ * **Traditional backends: **
134+
135+ * :mod: `dbm.gnu ` and :mod: `dbm.ndbm `: Accept :class: `str ` and :class: `bytes `
136+ objects.
137+ * :mod: `dbm.dumb `: Accepts :class: `str ` and :class: `bytes ` objects;
138+ :class: `bytearray ` is acceptable as a value, but not as a key.
134139
135- * :mod: `dbm.gnu ` and :mod: `dbm.ndbm `: Accept :class: `str ` and :class: `bytes ` objects.
136- * :mod: `dbm.dumb `: Accepts :class: `str ` and :class: `bytes ` objects; :class: `bytearray ` is acceptable as a value, but not as a key.
137140* **SQLite backend ** (:mod: `dbm.sqlite3 `): Accepts :class: `str `, :class: `bytes `,
138141 :class: `int `, :class: `float `, :class: `bool `, :class: `bytearray `,
139142 :class: `memoryview `, and :class: `array.array ` objects.
140143
141- **Storage Format : **
144+ **Storage format : **
142145
143146All keys and values are stored as :class: `bytes ` objects in the database.
144147When retrieving, you'll always get bytes back, regardless of the original
145148type stored.
146149
147- **Type Conversion Examples : **
150+ **Type conversion examples : **
148151
149152* ``db['key'] = 'string' `` stored as ``b'string' ``
150- * ``db['key'] = bytearray(b'data') `` stored as ``b'data' `` (:mod: `dbm.dumb ` and :mod: `dbm.sqlite3 ` only)
153+ * ``db['key'] = bytearray(b'data') `` stored as ``b'data' ``
154+ (:mod: `dbm.dumb ` and :mod: `dbm.sqlite3 ` only)
151155* ``db['key'] = 42 `` stored as ``b'42' `` (:mod: `dbm.sqlite3 ` only)
152156* ``db['key'] = 3.14 `` stored as ``b'3.14' `` (:mod: `dbm.sqlite3 ` only)
153157* ``db['key'] = True `` stored as ``b'1' `` (:mod: `dbm.sqlite3 ` only)
154158* ``db['key'] = False `` stored as ``b'0' `` (:mod: `dbm.sqlite3 ` only)
155- * ``db['key'] = memoryview(b'data') `` stored as ``b'data' `` (:mod: `dbm.sqlite3 ` only)
156- * ``db['key'] = array.array('i', [1, 2, 3]) `` stored as bytes (e.g. on little-endian: ``b'\x01\x00\x00\x00\x02\x00\x00\x00\x03\x00\x00\x00' ``) (:mod: `dbm.sqlite3 ` only)
159+ * ``db['key'] = memoryview(b'data') `` stored as ``b'data' ``
160+ (:mod: `dbm.sqlite3 ` only)
161+ * ``db['key'] = array.array('i', [1, 2, 3]) `` stored as bytes (for example, on
162+ little-endian: ``b'\x01\x00\x00\x00\x02\x00\x00\x00\x03\x00\x00\x00' ``)
163+ (:mod: `dbm.sqlite3 ` only)
157164
158165
159166The following example records some hostnames and a corresponding title, and
0 commit comments