Message307459
Guido specifically rejected __len__ for iterators when the iteration protocol was designed. This has become a FREQ in recent times (Frequently Rejected Enhancement Request :)
The rationale, as I understand it, is that an iterator object should always evaluate to True in a boolean context, but I don't know why. There is also a consistency argument: since not all iterators *can* have a len, then none should, because if some did and some didn't you couldn't use iterators interchangeably in code the way you can now. In other words, you can't make __len__ part of the iterator protocol, so iterators don't have a __len__. |
|
| Date |
User |
Action |
Args |
| 2017-12-02 21:18:24 | r.david.murray | set | recipients:
+ r.david.murray, steven.daprano, bugale bugale |
| 2017-12-02 21:18:24 | r.david.murray | set | messageid: <1512249504.51.0.213398074469.issue32172@psf.upfronthosting.co.za> |
| 2017-12-02 21:18:24 | r.david.murray | link | issue32172 messages |
| 2017-12-02 21:18:24 | r.david.murray | create | |
|