[Python-ideas] iterator length
Scott Dial
scott+python-ideas at scottdial.com
Tue Aug 10 18:39:49 CEST 2010
On 8/9/2010 4:17 PM, Alexandru Moșoi wrote:
> 2010/8/9 Paul Moore <p.f.moore at gmail.com>:
>> If you could show some real code that uses your ilen function, that
>> would help clarify.
>
> My requirements was to count the non-zero elements from a list like this:
> sum(1 for e in iterator if not e)
>
> What I'm really looking for is the number of elements in a list comprehension:
> len(list(for e in iterator if not e))
You are responding to his request for a specific example with a generic
class of examples, which is what prompted his request for a specific
example in the first place. Please give a *specific* example and be
prepared to be told that you are going about it the wrong way, since, at
this point, nobody has replied as having recognized this as a problem
they've encountered before.
--
Scott Dial
scott at scottdial.com
scodial at cs.indiana.edu
More information about the Python-ideas
mailing list