On Fri, 2007-06-15 at 14:39 -0400, Carsten Haese wrote: > class WhereTrue(object): > def __init__(self, func): > self.func = func > def __eq__(self, other): > return self.func(other) > > list1.count(WhereTrue(callable1)) > list2.count(WhereTrue(callable2))
P.S: Note, however, that this will only work if the list elements don't define __eq__ methods themselves. If they do, their __eq__ methods get called instead of WhereTrue's __eq__ method, leading to incorrect results. -- Carsten Haese http://informixdb.sourceforge.net -- http://mail.python.org/mailman/listinfo/python-list