Monica Leko wrote:
Hi

I have a specific format and I need binary representation.  Does
Python have some built-in function which will, for instance, represent
number 15 in exactly 10 bits?

   The "struct" module will let you format Python data as a binary
object of specified format.  But it doesn't support arbitrary bit-width
fields; integers can be 1, 2, 4, or 8 bytes.

   If you have a space problem, you might use the "struct" module to
convert to a reasonably concise binary representation, then use the
"gzip" module to compress the file down further.

                                        John Nagle
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to