a_list.count(a_callable) ?

Carsten Haese carsten at uniqsys.com
Fri Jun 15 12:33:16 EDT 2007


On Fri, 2007-06-15 at 14:15 +0000, Ping wrote:
> using sum(1 ...) to mean count() isn't very intuitive

I find it very intuitive, but then again, my years of studying Math may
have skewed my intuition.

> I would still prefer an expression like a_list.count(a_callable),
> which is short, clean, and easy to understand.

Did you see my alternative example on this thread? It allows you to use
list.count in almost exactly that way, except that instead of passing
the callable directly, you pass an object that defers to your callable
in its __eq__ method.

HTH,

-- 
Carsten Haese
http://informixdb.sourceforge.net





More information about the Python-list mailing list