[Python-ideas] Why is there a callable predicate, but no iterable?

Quentin Gallet-Gilles qgallet at gmail.com
Fri Sep 25 16:43:18 CEST 2009

On Fri, Sep 25, 2009 at 4:34 PM, Andrey Fedorov <anfedorov at gmail.com> wrote:

> So there was a discussion back in April [0] about the lack of an "iterable"
> predicate, which Pascal pointing out that the intention may be to use
> "isinstance(obj, Iterable)" instead. That seems inconsistent with the
> existence of collections.Callable (so, isinstance(obj, Callable) instead of
> callable(obj)).
> Which direction is this more likely to be resolved? Should I write
> iterable(obj) or expect callable(obj) to be deprecated?

The latter : callable() has been removed in Python 3 and the new way is to
check the existence of the __call__() method => hasattr(obj, '__call__')

> - Andrey
> 0. http://mail.python.org/pipermail/python-ideas/2009-April/004382.html
> _______________________________________________
> Python-ideas mailing list
> Python-ideas at python.org
> http://mail.python.org/mailman/listinfo/python-ideas

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20090925/e2c9ea86/attachment.html>

More information about the Python-ideas mailing list