[docs] [issue10609] dbm documentation example doesn't work (iteritems())

Éric Araujo report at bugs.python.org
Thu Dec 16 02:28:37 CET 2010

Éric Araujo <merwok at netwok.org> added the comment:

IMO, wrapping db in a dict defeats the purpose of dbm implementing a mapping interface.  I would use the most natural mapping idioms:

-   for k, v in db.iteritems():
-       print(k, '\t', v)
+   for k in db:
+       print(k, '\t', db[k])

The downside of this example is that it does not explicitely call methods, making the comment about “Other dictionary methods” strange.


Python tracker <report at bugs.python.org>

More information about the docs mailing list