[issue11775] `bool(Counter({'a': 0})) is True`

2011-04-05 Thread Raymond Hettinger
Raymond Hettinger added the comment: > How is it "not the Python way"? Because having an API within an API greatly complexifies the interface, making harder to implement, harder to understand, and harder to learn. > Why is it okay to make `dict.keys` into a smart object > but it's not okay t

[issue11775] `bool(Counter({'a': 0})) is True`

2011-04-05 Thread Ram Rachum
Ram Rachum added the comment: How is it "not the Python way"? Why is it okay to make `dict.keys` into a smart object but it's not okay to make `Counter.elements` a smart object? These are not random ideas. I'm using `Counter` in a contract project and I find the need to make `if counter:` che

[issue11775] `bool(Counter({'a': 0})) is True`

2011-04-05 Thread Raymond Hettinger
Raymond Hettinger added the comment: We could do that, but that's not the Python way :-) Really, you should be posting recipes somewhere else to see if there is interest and uptake. The tracker is not the right place to toss one random idea after another. We need to place some value on API

[issue11775] `bool(Counter({'a': 0})) is True`

2011-04-05 Thread Ram Rachum
Ram Rachum added the comment: Hmm... So how about making `elements` a smart object which will implement `__bool__`? Then we could give it a `__len__` too and be rid of issue11733. -- ___ Python tracker __

[issue11775] `bool(Counter({'a': 0})) is True`

2011-04-05 Thread Raymond Hettinger
Raymond Hettinger added the comment: Sorry, this is at odds with how Guido wants bool to work with containers. The bool check is all about whether or not a container is empty, not about its contents. -- resolution: -> invalid status: open -> closed _

[issue11775] `bool(Counter({'a': 0})) is True`

2011-04-05 Thread Matthew Barnett
Matthew Barnett added the comment: It depends on what kind of object it's like. If it's like a dict then your example is clearly not empty, but if it's like a set then it /is/ empty, in which case it's empty if: all(count == 0 for count in my_counter.values()) -- nosy: +mrabarnet

[issue11775] `bool(Counter({'a': 0})) is True`

2011-04-05 Thread Ram Rachum
Ram Rachum added the comment: Before coding a test I want to know whether we can even make this change with regards to backwards compatibility. -- ___ Python tracker ___ __

[issue11775] `bool(Counter({'a': 0})) is True`

2011-04-05 Thread Ezio Melotti
Changes by Ezio Melotti : -- nosy: +ezio.melotti, rhettinger stage: -> test needed type: -> behavior ___ Python tracker ___ ___ Pyth

[issue11775] `bool(Counter({'a': 0})) is True`

2011-04-05 Thread Ram Rachum
Changes by Ram Rachum : -- title: `bool(Counter({'a': 0'})) is True` -> `bool(Counter({'a': 0})) is True` ___ Python tracker ___ ___ P

[issue11775] `bool(Counter({'a': 0'})) is True`

2011-04-05 Thread Ram Rachum
New submission from Ram Rachum : bool(Counter({'a': 0'})) is True. Is this wise? I want to be able to do: if my_counter: whatever To check whether my counter has any elements. Currently this seems to be impossible because of this bug. Will we have to keep this weird behavior beca