Message257303
| Author |
abarnert |
| Recipients |
abarnert, martin.panter, ncoghlan, r.david.murray, serhiy.storchaka |
| Date |
2016年01月01日.21:25:14 |
| SpamBayes Score |
-1.0 |
| Marked as misclassified |
Yes |
| Message-id |
<1451683514.66.0.370992724909.issue25958@psf.upfronthosting.co.za> |
| In-reply-to |
| Content |
> I don’t think you need to define __len__() to get an iterable, only __getitem__().
The "old-style sequence protocol" means having a __getitem__ that works for values from 0 to __len__() and raises IndexError at __len__(). You don't need to be a complete old-style sequence to be iterable; just having __getitem__ makes you iterable (without being a collections.abc.Iterable or a typing.Iterable), and having __getitem__ and __len__ makes you reversible (without being a typing.Reversible). At any rate, this bug isn't about avoiding false negatives for the implicit ABCs, but false positives: defining __iter__ = None blocks the old-style sequence protocol, but makes isinstance(Iterable) true. |
|