def hex_encode(data, errors='strict'):
 return (serial.to_bytes([int(h, 16) for h in data.split()]), len(data))

def hex_encode ( data , errors = 'strict' ) : return ( serial . to_bytes ( [ int ( h , 16 ) for h in data . split ( ) ] ) , len ( data ) )
encodes the object input and returns a tuple .