"Many dictionary methods, like keys and items, also work with database objects. So does
iteration with a for statement."
example code from book...
import anydbm
db = anydbm.open('captions.db', 'c')
db['cleese.png'] = 'Photo of John Cleese doing a silly walk.'
for key in db:
print key
running this code on my computer, the following error was thrown.
Traceback (most recent call last):
File "", line 1, in
TypeError: 'dbm.dbm' object is not iterable
Therefore, iteration with a for statement does not work on database objects as described above.
"Many dictionary methods, like keys and items, also work with database objects. So does
iteration with a for statement."
example code from book...
running this code on my computer, the following error was thrown.
Traceback (most recent call last):
File "", line 1, in
TypeError: 'dbm.dbm' object is not iterable
Therefore, iteration with a for statement does not work on database objects as described above.