On 6/16/07, Dustan <[EMAIL PROTECTED]> wrote: > On Jun 16, 3:37 pm, Dustan <[EMAIL PROTECTED]> wrote: > > class SmartCountingList(list): > > def count(self, item, func=lambda x: x): > > return sum(1 for i in self if func(item)==item) > > > > Then, you would call it as follows: > > a_list.count(True, a_function) > > I need to learn to think things through before hitting the send button > (or test my examples); none of the mistakes I've made on this thread > have been from ignorance. > > If a_function returns a true value other than True or the number 1 > (which are technically the same), it is not 'equal' to True. Either
If you're _really_ pedantic, 1 and True are _not_ the same, and this can be an important distinction in some situations. >>> 1 == True True >>> 1 is True False -- Evan Klitzke <[EMAIL PROTECTED]> -- http://mail.python.org/mailman/listinfo/python-list