I would like to pack all the data in a list into a single buffer to send over a UDP socket. The list is relatively long, so indexing each element in the list is tedious. This is what I have so far:
NumElements = len(data)
buf = struct.pack('d'*NumElements,data[0],data[1],data[2],data[3],data[4])
But I would like to do something more pythonic that doesn't require I change the call if I added more elements to the list... something like:
NumElements = len(data)
buf = struct.pack('d'*NumElements,data) # Returns error
Is there a good way of doing this??