[Python-ideas] A meaningful `if counter:`

cool-RR cool-rr at cool-rr.com
Wed Apr 6 16:29:20 CEST 2011


On Wed, Apr 6, 2011 at 4:24 PM, Bruce Leban <bruce at leapyear.org> wrote:

> Nope.
>
> >>> c = Counter()
> >>> c[0] = -1
> >>> c.elements()
> []
> >>> c.values()
> dict_values([-1])
> >>> any(c.values())
> True  # FAIL
> >>> any(True for i in c.elements())
> False
>
> --- Bruce
>
>
Hm. Then maybe a `Counter.elements().__bool__` method would be helpful.


Ram.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20110406/7a84b460/attachment.html>


More information about the Python-ideas mailing list