Commit e398da9a authored by Georg Brandl's avatar Georg Brandl

#10609: fix non-working dbm example.

parent e9e8c9bd
...@@ -91,10 +91,8 @@ then prints out the contents of the database:: ...@@ -91,10 +91,8 @@ then prints out the contents of the database::
# Notice how the value is now in bytes. # Notice how the value is now in bytes.
assert db['www.cnn.com'] == b'Cable News Network' assert db['www.cnn.com'] == b'Cable News Network'
# Loop through contents. Other dictionary methods # Often-used methods of the dict interface work too.
# such as .keys(), .values() also work. print(db.get('python.org', b'not present'))
for k, v in db.iteritems():
print(k, '\t', v)
# Storing a non-string key or value will raise an exception (most # Storing a non-string key or value will raise an exception (most
# likely a TypeError). # likely a TypeError).
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment