There is file as bytes in book.
class tobinary: def binarydata(self, filename): with open(filename, \'rb\') as file: blobdata = bytear