On Thu, 2007-06-14 at 21:06 +0000, Dustan wrote: > On Jun 14, 3:37 pm, Dustan <[EMAIL PROTECTED]> 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)) -- Carsten Haese http://informixdb.sourceforge.net -- http://mail.python.org/mailman/listinfo/python-list