def __call__(self,**kw):
        """Selection by field values
        db(key=value) returns the list of records where r[key] = value"""
        for key in kw:
            if not key in self.fields:
                raise ValueError,"Field %s not in the database" %key
        def sel_func(r):
            for key in kw:
                if not r[key] == kw[key]:
                    return False
            return True
        return [ r for r in self if sel_func(r) ]
Selection by field values
        db(key=value) returns the list of records where r[key] = value
recipes/Python/496770_PyDbLite_small_inmemory_database/recipe-496770.py