Re: Write bits in file

2008-05-23 Thread Andrew Lee
Tim Roberts wrote: Monica Leko <[EMAIL PROTECTED]> wrote: 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? For the record, I'd like to point out that even C cannot do this. You

Re: Write bits in file

2008-05-21 Thread Tim Roberts
"[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote: >On May 20, 12:14 am, Tim Roberts <[EMAIL PROTECTED]> wrote: >> Monica Leko <[EMAIL PROTECTED]> wrote: >> >> >I have a specific format and I need binary representation. Does >> >Python have some built-in function which will, for instance, represent >>

Re: Write bits in file

2008-05-20 Thread [EMAIL PROTECTED]
On May 20, 12:14 am, Tim Roberts <[EMAIL PROTECTED]> wrote: > Monica Leko <[EMAIL PROTECTED]> wrote: > > >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? > > For the record, I

Re: Write bits in file

2008-05-20 Thread castironpi
On May 20, 10:30 am, Nick Craig-Wood <[EMAIL PROTECTED]> wrote: > Monica Leko <[EMAIL PROTECTED]> wrote: > >  On May 18, 2:20?pm, Ken Starks <[EMAIL PROTECTED]> wrote: > > > You want your file considered as a sequence of bits rather > > > than a sequence of 8-bit bytes, do you? > > >  Yes. > > > >

Re: Write bits in file

2008-05-20 Thread Nick Craig-Wood
Monica Leko <[EMAIL PROTECTED]> wrote: > On May 18, 2:20?pm, Ken Starks <[EMAIL PROTECTED]> wrote: > > You want your file considered as a sequence of bits rather > > than a sequence of 8-bit bytes, do you? > > Yes. > > > is the 10-bit bit-pattern to be stored at an arbitrary > > bit-position in

Re: Write bits in file

2008-05-20 Thread pataphor
On Sun, 18 May 2008 06:36:28 -0700 (PDT) Monica Leko <[EMAIL PROTECTED]> wrote: > Yes. I need arbitrary, 8bits, than 10 bits for something else, than > sequence of bytes, than 10 bits again, etc. Here's something to get you started. No guarantees, but I managed to write four 10 bit numbers to a

Re: Write bits in file

2008-05-19 Thread Tim Roberts
Monica Leko <[EMAIL PROTECTED]> wrote: > >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? For the record, I'd like to point out that even C cannot do this. You need to use shift

Re: Write bits in file

2008-05-19 Thread Scott David Daniels
Monica Leko wrote: On May 18, 2:20 pm, Ken Starks <[EMAIL PROTECTED]> wrote: You want your file considered as a sequence of bits rather than a sequence of 8-bit bytes, do you? Yes. is the 10-bit bit-pattern to be stored at an arbitrary bit-position in the file Yes. I need arbitrary, 8bits,

Re: Write bits in file

2008-05-18 Thread John Nagle
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 doe

Re: Write bits in file

2008-05-18 Thread Ken Starks
I admit that I was mostly just interested in getting your question clarified, rather than having any great experise. But a bit of Googling took me to the 'Bit vector' module, [I googled: 'python ("bit array" OR "bit vector")'] which might be what you are after. I have no experience with it, mysel

Re: Write bits in file

2008-05-18 Thread Gabriel Genellina
En Sun, 18 May 2008 10:36:28 -0300, Monica Leko <[EMAIL PROTECTED]> escribió: > On May 18, 2:20 pm, Ken Starks <[EMAIL PROTECTED]> wrote: >> You want your file considered as a sequence of bits rather >> than a sequence of 8-bit bytes, do you? > > Yes. > >> is the 10-bit >> bit-pattern to be stored

Re: Write bits in file

2008-05-18 Thread Monica Leko
On May 18, 2:20 pm, Ken Starks <[EMAIL PROTECTED]> wrote: > You want your file considered as a sequence of bits rather > than a sequence of 8-bit bytes, do you? Yes. > is the 10-bit > bit-pattern to be stored at an arbitrary bit-position in > the file Yes. I need arbitrary, 8bits, than 10 bits

Re: Write bits in file

2008-05-18 Thread Ken Starks
You want your file considered as a sequence of bits rather than a sequence of 8-bit bytes, do you? is the 10-bit bit-pattern to be stored at an arbitrary bit-position in the file, or is the whole file regularly subdivided at 10-bit intervals? Monica Leko wrote: Hi I have a specific format and

Write bits in file

2008-05-18 Thread Monica Leko
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? -- http://mail.python.org/mailman/listinfo/python-list