Thus spoke [EMAIL PROTECTED] (on 2006-09-28 09:10):

> String formatting can be used to converting an integer to its octal or 
> hexadecimal form:
>  >>> a = 199
>  >>> "%o" % a
> '307'
>  >>> "%x" % a
> 'c7'
> 
> But, can string formatting be used to convert an integer to its binary 
> form ?

I didn't fell over this problem so far but
I *would* have expected to find something
like a 'pack' operator (as in Perl).

And voilá, there is (even basically identical to Perl):

  from struct import *

  a = 199
  a_bin_str = pack('L', a)



Regards

Mirco
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to