Exemplo n.º 1
0
 def __contains__(self, key):
     if isinstance(key, int):
         newbyteskey = newbytes([key])
     # Don't use isinstance() here because we only want to catch
     # newbytes, not Python 2 str:
     elif type(key) == newbytes:
         newbyteskey = key
     else:
         newbyteskey = newbytes(key)
     return issubset(list(newbyteskey), list(self))
Exemplo n.º 2
0
 def __contains__(self, key):
     errmsg = "'in <string>' requires string as left operand, not {0}"
     # Don't use isinstance() here because we only want to catch
     # newstr, not Python 2 unicode:
     if type(key) == newstr:
         newkey = key
     elif isinstance(key, unicode) or isinstance(key, bytes) and not isnewbytes(key):
         newkey = newstr(key)
     else:
         raise TypeError(errmsg.format(type(key)))
     return issubset(list(newkey), list(self))