[New-bugs-announce] [issue10609] dbm documentation example doesn't work (iteritems())

Sandro Tosi report at bugs.python.org
Thu Dec 2 21:52:06 CET 2010


New submission from Sandro Tosi <sandro.tosi at gmail.com>:

Following http://mail.python.org/pipermail/docs/2010-December/002356.html a possible solution is:


diff -r 3b07f7bb0289 Doc/library/dbm.rst
--- a/Doc/library/dbm.rst       Thu Dec 02 19:29:18 2010 +0100
+++ b/Doc/library/dbm.rst       Thu Dec 02 21:51:06 2010 +0100
@@ -88,7 +88,7 @@
 
    # Loop through contents.  Other dictionary methods
    # such as .keys(), .values() also work.
-   for k, v in db.iteritems():
+   for k, v in dict(db).items():
        print(k, '\t', v)
 
    # Storing a non-string key or value will raise an exception (most

How much ugly is this? alternatively, we can:


>>> for k in db.keys():
...     print(k, '\t', db.get(k))

What would be the best solution? (anyhow the comments above the for loop has to be changed).

Regards,
Sandro

----------
messages: 123113
nosy: sandro.tosi
priority: normal
severity: normal
status: open
title: dbm documentation example doesn't work (iteritems())

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue10609>
_______________________________________


More information about the New-bugs-announce mailing list