I'm trying to convert int numbers (>=0 && <2^32 of course) in Python into a 4 byte unsigned int representation and back.
As I understand the docs the sizes given in struct.pack are a standard but the size is not guaranteed.. how can I make sure that I get 4 exactly bytes?
One way I found using ctypes:
byte_repr=bytes(ctypes.c_uint32(data))
Is this the most pythonic one there is? And what would be the way back (for this or any other solution)?