Re: binascii.unhexlify ... not clear about usage, and output

2007-07-11 Thread Gabriel Genellina
En Wed, 11 Jul 2007 17:34:04 -0300, [EMAIL PROTECTED] <[EMAIL PROTECTED]> escribió: > If only there was a built-in base 2 conversion. No builtin, but you can find uncountable versions if you search this group, or the Python cookbook, or the entire web... -- Gabriel Genellina -- http://mai

Re: binascii.unhexlify ... not clear about usage, and output

2007-07-11 Thread [EMAIL PROTECTED]
On Jul 11, 1:38 pm, Marc 'BlackJack' Rintsch <[EMAIL PROTECTED]> wrote: > On Wed, 11 Jul 2007 10:46:23 -0700, [EMAIL PROTECTED] wrote: > > You can with gmpy: > > import gmpy > x = 0x0164 > s = gmpy.digits(x,2) # convert to base 2 > y = '0'*(16-len(s)) + s # pad to 16 bits

Re: binascii.unhexlify ... not clear about usage, and output

2007-07-11 Thread Marc 'BlackJack' Rintsch
On Wed, 11 Jul 2007 10:46:23 -0700, [EMAIL PROTECTED] wrote: > You can with gmpy: > import gmpy x = 0x0164 s = gmpy.digits(x,2) # convert to base 2 y = '0'*(16-len(s)) + s # pad to 16 bits y > '000101100100' For the padding I'd use the `zfill()` method. In [1

Re: binascii.unhexlify ... not clear about usage, and output

2007-07-11 Thread [EMAIL PROTECTED]
On Jul 11, 3:21 am, Vishal <[EMAIL PROTECTED]> wrote: > On May 30, 1:31 pm, Peter Otten <[EMAIL PROTECTED]> wrote: > > > > > > > Vishal wrote: > > > I have a file with a long list of hex characters, and I want to get a > > > file with corresponding binary characters > > > > here's what I did: > > >

Re: binascii.unhexlify ... not clear about usage, and output

2007-07-11 Thread Vishal
On May 30, 1:31 pm, Peter Otten <[EMAIL PROTECTED]> wrote: > Vishal wrote: > > I have a file with a long list of hex characters, and I want to get a > > file with corresponding binary characters > > > here's what I did: > > import binascii > f1 = 'c:\\temp\\allhex.txt' > f2 = 'c:\\te

Re: binascii.unhexlify ... not clear about usage, and output

2007-05-30 Thread Peter Otten
Vishal wrote: > I have a file with a long list of hex characters, and I want to get a > file with corresponding binary characters > > here's what I did: > import binascii f1 = 'c:\\temp\\allhex.txt' f2 = 'c:\\temp\\allbin.txt' sf = open(f1, 'rU') df = open(f2, 'w')