length = len(data) buff.write(_struct_I.pack(length)) pattern = '<%sh'%length buff.write(data.tostring())