This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author r.david.murray
Recipients bugale bugale, r.david.murray, steven.daprano
Date 2017-12-02.21:18:24
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1512249504.51.0.213398074469.issue32172@psf.upfronthosting.co.za>
In-reply-to
Content
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__.
History
Date User Action Args
2017-12-02 21:18:24r.david.murraysetrecipients: + r.david.murray, steven.daprano, bugale bugale
2017-12-02 21:18:24r.david.murraysetmessageid: <1512249504.51.0.213398074469.issue32172@psf.upfronthosting.co.za>
2017-12-02 21:18:24r.david.murraylinkissue32172 messages
2017-12-02 21:18:24r.david.murraycreate