carsten at uniqsys.com
Thu Jun 14 23:18:22 CEST 2007
On Thu, 2007-06-14 at 21:06 +0000, Dustan wrote:
> 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.
sum(1 for i in a_list if a_callable(i))
More information about the Python-list