[issue25513] collections.abc.Iterable don't implement __bool__

2015-10-29 Thread R. David Murray
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

[issue25513] collections.abc.Iterable don't implement __bool__

2015-10-29 Thread yoch
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))