R. David Murray added the comment:
This is as designed. The only method needed for something to qualify as an
Iterable is __iter__, thus this is the only method defined on the ABC. If you
want your Iterable to be usable in a boolean test, add the __bool__ method to
your concrete class.
In f
New submission from yoch:
collections.abc.Iterable don't implement the __bool__ method. This may
seriously degrade performance in case __len__ is not efficient.
I suggest to implement it as :
class Iterable:
...
def __bool__(self):
try:
next(iter(self))