[issue18558] Iterable glossary entry needs clarification
R. David Murray added the comment: “What is the proper way of asking if an object is iterable if it does not support the iterator protocol but does support the old getitem protocol?” The *only* answer to that question is to try to iterate it, and see if you get a KeyError on "0". Since this results in obtaining the first element if it *is* iterable, and in the general case you cannot "reset" an iterable, there is no way to look before you leap. You have to catch the error after it occurs. This question and answer probably do belong on Stack Overflow or python-list, but the glossary entry still needs improvement, since the Iterable docs reference it :) ---------- _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue18558> _______________________________________
participants (1)
-
R. David Murray