[Python-ideas] iterator length
Alexandru Moșoi
brtzsnr at gmail.com
Tue Aug 10 18:45:09 CEST 2010
2010/8/10 Scott Dial <scott+python-ideas at scottdial.com>:
> 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.
My exact need is to count the not-None elements in a list. My current
solution is, as described before:
sum(1 for e in iterator if not e)
--
Alexandru Moșoi
http://www.alexandru.mosoi.ro/
More information about the Python-ideas
mailing list