I am creating a function that will accept either a Unicode string or a byte object (or bytearray). I want to make sure that only those types are passed. I know that I can check if there is something string by running isinstance(x, str) , and I know that I can write isinstance(x, bytes) or isinstance(x, bytearray) .
Is there a shorter way to check for the latter, i.e. Is there a class from which both bytes and bytearray ?
source share