Skip to content

Instantly share code, notes, and snippets.

@hellpanderrr
Last active April 5, 2016 20:16
Show Gist options
  • Save hellpanderrr/09bc672638da56800e46 to your computer and use it in GitHub Desktop.
Save hellpanderrr/09bc672638da56800e46 to your computer and use it in GitHub Desktop.
python object is iterable
#'Iterable' means object has an __iter__() method.
isiterable = lambda obj: isinstance(obj, basestring) or bool(getattr(obj, '__iter__', False))
from collections import Iterable
isiterable = lambda obj: isinstance(obj, Iterable)
#https://docs.python.org/3/library/collections.abc.html#collections.abc.Iterable
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment