a_list.count(a_callable) ?

Ping ping.nsr.yeh at gmail.com
Fri Jun 15 13:55:11 EDT 2007


On 6 16 ,   12 33 , Carsten Haese <cars... at uniqsys.com> wrote:
> 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 Haesehttp://informixdb.sourceforge.net

Yes, I read it.  This works, but it may make lots of dummy classes
with the special __eq__ method if I have many criteria to use for
counting.  I find the function design mentioned by Dustan most
attractive.  :)

cheers,
Ping




More information about the Python-list mailing list