Created
August 6, 2015 13:31
-
-
Save afonasev/5a1ab9818c83e67cf162 to your computer and use it in GitHub Desktop.
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
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