Author veky
Recipients Zero, docs@python, r.david.murray, rhettinger, terry.reedy, veky
Date 2017-07-17.15:47:49
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
Yes, the mapping/sequence distinction was (at least declaratively) the reason the ABCs were introduced, but that isn't an obstacle here: whether a mapping or a sequence, it _is_ iterable, right?


In case anybody is interested, here's how I came to this problem: at a programming competition, I set a problem where contestants had to write some function, and I declared that "the function must work for arbitrary iterable (with some properties that currently don't matter)".

Then a big discussion ensued, with a big group of people thinking that classes with __getitem__ but no __iter__ don't quality (giving as an argument), and another big group of people thinking they do (giving EAFP as an argument: "look, I tried iterating, and succeeded").

Of course, it's an incredibly technical detail, but I don't like such gray areas. To me, things with __getitem__ are clearly iterable - the glossary says so:-). Iterable's instancecheck is simply buggy ("incomplete", if you want). There might be valid reasons for keeping it buggy, but they should be documented.
Date User Action Args
2017-07-17 15:47:49vekysetrecipients: + veky, rhettinger, terry.reedy, r.david.murray, Zero, docs@python
2017-07-17 15:47:49vekysetmessageid: <>
2017-07-17 15:47:49vekylinkissue18558 messages
2017-07-17 15:47:49vekycreate