John Belmonte <j...@neggie.net> added the comment:
> Just a comment, (1) is analogous to str. iter('abc') gives only 'a', 'b' and > 'c', while contains accepts '', 'ab', 'bc', and 'abc' too. At least in my > mind, it's a pretty strong analogy. I don't agree. The "zero" bit does not exist, so having __contains__ return True on `Foo(0) in x` is misaligned with the iterator. And having __contains__ return True for specific compound values just because they happen to be explicitly defined, while returning False for others, is arbitrary. __contains__ seems to be of very little use, and moreover a trap for the unwary. Assuming we have to live with that until Python 4, it's better to make an explicit iterator like `bits()` so that the API doesn't contradict itself. ---------- _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue38250> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com