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
....
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.
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
.... print kimport gdbm
d = gdbm.open("spam.db", "n")
d["key1"] = "ham"
d["key2"] = "spam"
for k in d:
....
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.