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

Raymond Hettinger raymond.hettinger at gmail.com
Wed Apr 6 09:57:43 CEST 2011


On Apr 5, 2011, at 11:59 PM, cool-RR wrote:

> Okay, this argument applies against `Counter.__bool__`, but not against `Counter.elements().__bool__`. So I want to hear whether people would find a  `Counter.elements().__bool__` method useful.
> 



if any(c.elements()):
    ...


Raymond




More information about the Python-ideas mailing list