Stephen Paul Chappell added the comment:

Maybe this would have been more appropriate as a question on StackOverflow:

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? One 
might argue that it is better to ask for forgiveness rather than permission, 
but that does not really answer the question.

My impression of collections.abc.Iterable is that programmers can use it to ask 
if an object is iterable. Some argue that it is better to ask for forgiveness 
rather that permission and would suggest pretending that an object is iterable 
until it is proven otherwise. However, what do we use 
collections.abc.Iterable’s for then?

The true question is really, “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?” More generically, how can you ask an object if it supports 
ANY iteration protocol? The query probably should have been posted on 
StackOverflow and not here.

This may not be a problem with collections.abc.Iterable, and thus the issue 
should be closed. However, the previous question remains, and it is apparent 
that it cannot be answered with the abstract class as it currently is. Maybe 
the solution is to just ask for forgiveness where appropriate.

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue18558>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to