]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
#10609: fix non-working dbm example.
authorGeorg Brandl <georg@python.org>
Tue, 28 Dec 2010 11:53:25 +0000 (11:53 +0000)
committerGeorg Brandl <georg@python.org>
Tue, 28 Dec 2010 11:53:25 +0000 (11:53 +0000)
Doc/library/dbm.rst

index 67c0025fe9d944960c7a5c26009fd7702846f285..0cd873e8d469f5168d4044acea29ee6ef8ff20a9 100644 (file)
@@ -91,10 +91,8 @@ then prints out the contents of the database::
    # Notice how the value is now in bytes.
    assert db['www.cnn.com'] == b'Cable News Network'
 
-   # Loop through contents.  Other dictionary methods
-   # such as .keys(), .values() also work.
-   for k, v in db.iteritems():
-       print(k, '\t', v)
+   # Often-used methods of the dict interface work too.
+   print(db.get('python.org', b'not present'))
 
    # Storing a non-string key or value will raise an exception (most
    # likely a TypeError).