I'm learning about database files and the dbm module in Python 3.1.3, and am having trouble using some of the methods from the anydbm module in Python 2.
The keys method works fine,
import dbm
db = dbm.open('dbm', 'c')
db['modest'] = 'mouse'
db['dream'] = 'theater'
for key in db.keys():
print(key)
yields:
b'modest'
b'dream'
but items and values,
for k,v in db.items():
print(k, v)
for val in db.values():
print(val)
bring up an AttributeError: '_dbm.dbm' object has no attribute 'items'.
Also, this:
for key in db:
print(key)
gets a TypeError: '_dbm.dbm' object is not iterable.
Do these methods just not work in the dbm module in Python 3? If that's true, is there anything else that I could use instead?