[pybsddb] Please add this simple function

Yong Li codercoder at 10gic.net
Wed Apr 8 06:55:01 CEST 2009


Hi,

Please add a __contains__ to the DB object in pybsddb. Right now if you do

key in db

Python treats db as a iterable and iterates across the entire db
because there is no __contains__ but there is an __iter__. Please add
this to DB:

def __contains__(self, key):
    return self.has_key(key)


Just these two lines will make pybsddb more Pythonic and prevent quite
a few bugs.


I had already asked for this feature before and it was apparently
approved, but it was forgotten about? Maybe having a bug tracker will
help keep track of these little requests?

Sincerely,
Yongqian Li



More information about the pybsddb mailing list