Karthik Gurusamy a écrit :
> On Jul 17, 5:35 am, Bruno Desthuilliers <bruno.
> [EMAIL PROTECTED]> wrote:
>> mosi a écrit :
>>
>>
>>
>>> Problem:
>>> how to get binary from integer and vice versa?
>>> The simplest way I know is:
>>> a = 0100
>>> a
>>> 64
>>> but:
>>> a = 100 (I want binary number)
>>> does not work that way.
>>> a.__hex__   exists
>>> a.__oct__ exists
>>> but where is a.__bin__ ???
>>> What`s the simplest way to do this?
(snip)
>>  >>> a = int('100', 2)
>>  >>> a
>> 4
(snip)
> While it's interesting to know we can go from binary to int, the OP
> wanted the other way.

Please reread more carefully the OP's question and code snippet (which 
are just above).

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

Reply via email to