Author Zero
Recipients Zero, docs@python, r.david.murray, terry.reedy
Date 2013-08-01.21:46:11
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1375393572.01.0.442284358787.issue18558@psf.upfronthosting.co.za>
In-reply-to
Content
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.
History
Date User Action Args
2013-08-01 21:46:12Zerosetrecipients: + Zero, terry.reedy, r.david.murray, docs@python
2013-08-01 21:46:12Zerosetmessageid: <1375393572.01.0.442284358787.issue18558@psf.upfronthosting.co.za>
2013-08-01 21:46:11Zerolinkissue18558 messages
2013-08-01 21:46:11Zerocreate