I am trying to understand one of the python function called bytearray(). Adding a decimal value to this object will give you hex representation of bytearray. But in the range of 33-126 its giving ASCII character representation of bytearray. So problem here is if i construct a bytearray in python and send to our other module of the project which written in C-language, so what will they expect from that bytearray representation, is it will be complete hex representation or mix of something ?
Example-1:
s = bytearray()
s.append(10)
print(s) # bytearray(b'\n') . What kind of representation it is?
Example-2:
s = bytearray()
s.append(20)
print(s) # bytearray(b'\x14') . hex representation
Example-3:
s = bytearray()
s.append(20)
print(s) # bytearray(b'$') . ASCII representation
Can somebody explain what is the reason behind this?