Message378455
> 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. |
|
Date |
User |
Action |
Args |
2020-10-11 21:26:22 | John Belmonte | set | recipients:
+ John Belmonte, ethan.furman, veky, Manjusaka |
2020-10-11 21:26:22 | John Belmonte | set | messageid: <1602451582.36.0.26779419543.issue38250@roundup.psfhosted.org> |
2020-10-11 21:26:22 | John Belmonte | link | issue38250 messages |
2020-10-11 21:26:22 | John Belmonte | create | |
|