On Thu, Feb 24, 2011 at 09:07:16AM +0100, Rene Nussbaumer wrote: > On Wed, Feb 23, 2011 at 4:57 PM, Michael Hanselmann <[email protected]> wrote: > > Am 23. Februar 2011 10:41 schrieb René Nussbaumer <[email protected]>: > >> + results = jex.GetResults() > >> + bad_cnt = sum(1 for (success, _) in results if not success) > > > > Please use len(), not sum(). > > Please make up your mind then :). Either you want me to use a > generator for memory optimization or your want me to use len(). Both > are not working together, because generators do not have a length. > Which make sense as a generator can generate an infinite amount of > data where a len wouldn't work on (hint: Fibonacci sequence to call a > well known example). So what do you want me to do?
Hah: >>> len(i for i in range(5)) Traceback (most recent call last): File "<stdin>", line 1, in <module> TypeError: object of type 'generator' has no len() >>> I believe that hansmi was again trying to optimize things that not need optimization… regards, iustin
