Skip to content

Instantly share code, notes, and snippets.

@afonasev
Created August 6, 2015 13:31
Show Gist options
  • Save afonasev/5a1ab9818c83e67cf162 to your computer and use it in GitHub Desktop.
Save afonasev/5a1ab9818c83e67cf162 to your computer and use it in GitHub Desktop.
import collections
class NoStrIterable(collections.Iterable):
"""
'isinstance(smt, NoStrIterable)'
instead of
'isinstance(smt, collection.Iterable) and not isinstance(smt, str)'
"""
@classmethod
def __subclasshook__(cls, obj):
return (
not issubclass(obj, (str, bytes))
and collections.Iterable.__subclasshook__(obj)
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment