<br><div class="gmail_quote"><br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">I have following packet format which I have to send over Bluetooth.<br>

<br>
packet_type (1 byte unsigned) || packet_length (1 byte unsigned) ||<br>
packet_data(variable)<br>
<br>
How to construct these using python data types, as int and float have<br>
no limits and their sizes are not well defined.</blockquote><div><br>Check out the struct module.<br><br>You want something like:<br><br>  data = struct.pack("BB4s", 1, 4, "this")<br><br>It returns a string of bytes according to the specification -- B is unsigned byte, and "4s" is a string of 4 characters. The 1 feeds into the first byte, the 4 into the second, etc.<br>
<br>--Stephen<br></div></div><br>