Why is it that *dbm modules don't provide an iterator? (Languagedesign question)

A

Akira Kitada

Hi,

I was wondering why *dbm modules in Python do not give us an iterable interface?
Take a look at an example below

"""
# Python 2.6
import gdbm
d = gdbm.open("spam.db", "n")
d["key1"] = "ham"
d["key2"] = "spam"

for k in d:
.... print k
....
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: 'gdbm.gdbm' object is not iterable
"""

The loop has to be:
""".... print k
.... k = d.nextkey(k)
key2
key1
"""

I would like to know the background of this design decision.
Some research on this led me to this ticket:

http://bugs.python.org/issue662923

It looks I'm not the only one who wondered on this.

Thanks in advance.
 

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top