Created
December 16, 2015 22:40
-
-
Save jriddy/7b1098e0fbda52ee81f8 to your computer and use it in GitHub Desktop.
This file contains 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
def iterable_nonstring(x): | |
"""Determines whether an object is iterable and not a string or unicode. | |
This is incorrect for python 3. | |
""" | |
return hasattr(x, '__iter__') | |
def iterable(x): | |
"""Determines whether an object can be iterated over. | |
The `or` is unneccesary for python 3. | |
""" | |
return iterable_nonstring(x) or isinstance(x, basestring) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment