Last active
April 5, 2016 20:16
-
-
Save hellpanderrr/09bc672638da56800e46 to your computer and use it in GitHub Desktop.
python object is iterable
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#'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