R. David Murray <rdmur...@bitdance.com> added the comment: 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__. ---------- nosy: +r.david.murray _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue32172> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com