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 > '0000000101100100'
For the padding I'd use the `zfill()` method. In [15]: a = 0x0164 In [16]: gmpy.digits(a, 2).zfill(16) Out[16]: '0000000101100100' Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list