length = len(data) buff.write(_struct_I.pack(length)) pattern = '<%sB'%length buff.write(struct.pack(pattern, *data))