Ping wrote: > On 6 16 , 2 06 , "BJörn Lindqvist" <[EMAIL PROTECTED]> wrote: > >> Maybe you could extend count() analogous to how sort() works: >> > > Wow! This jumps out of my screen! I like it very much. > How to get the extension into the language? > Well, you subclass list and extend/override the method.
class SmartCountingList(list): def count(self, item, func=lambda x: x): return len([item for item in self if func(item) is True]) ... or whatever (this is dummy code, not tested and probably riddled with stupid errors --- so take this as a pseudocode example) /W -- http://mail.python.org/mailman/listinfo/python-list