[Python-ideas] having a "iterable" built-in
Adam Atlas
adam at atlas.st
Thu Apr 30 00:08:33 CEST 2009
I don't think that's going to happen. The similar builtin "callable"
has been removed as of Python 3.0 in favour of isinstance(x,
collections.Callable), or in versions < 2.6, hasattr(x, '__call__'),
and the convention is similar for iterables ("isinstance(x,
collections.Iterable)" or "hasattr(x, '__iter__')").
On 29 Apr 2009, at 14:47, Tarek Ziadé wrote:
> Hello
>
> unless I missed it, I couldn't find a built-in to check if an object
> is iterable,
>
> so I wrote this function :
>
> def iterable(ob):
> try:
> iter(ob)
> except TypeError:
> return False
> return True
>
>
> What about having such a built-in in Python ? (with the proper
> implementation if course)
>
> Regards
> Tarek
>
> --
> Tarek Ziadé | http://ziade.org
> _______________________________________________
> Python-ideas mailing list
> Python-ideas at python.org
> http://mail.python.org/mailman/listinfo/python-ideas
More information about the Python-ideas
mailing list