Skip to content

Database keys are not iterable as described in 14.6  #3

Description

@mattall

"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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions