
Author: georg.brandl Date: Tue Dec 28 12:53:25 2010 New Revision: 87536 Log: #10609: fix non-working dbm example. Modified: python/branches/py3k/Doc/library/dbm.rst Modified: python/branches/py3k/Doc/library/dbm.rst ============================================================================== --- python/branches/py3k/Doc/library/dbm.rst (original) +++ python/branches/py3k/Doc/library/dbm.rst Tue Dec 28 12:53:25 2010 @@ -91,10 +91,8 @@ # 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).
participants (1)
-
georg.brandl