a_list.count(a_callable) ?

Dustan DustanGroups at gmail.com
Thu Jun 14 23:06:24 CEST 2007

On Jun 14, 3:37 pm, Dustan <DustanGro... at gmail.com> wrote:
> Which can then be converted into a generator expression (round
> brackets instead of square brackets) to avoid the intermediate list:
> len((i for i in a_list if a_callable(i)))

Sorry for the excess of posts everybody.

I just realized that the generator expression would not work. I'm not
sure how else could be implemented efficiently and without using up
memory besides by accumulating the count as your earlier example shows.

More information about the Python-list mailing list