class myint (int): def __bytes__ (self): return b"hello" i1 = int (1) i2 = myint (2) print (bytes (i1)) print (bytes (i2))