On 2006-09-29, Steve Holden <[EMAIL PROTECTED]> wrote:
> MonkeeSage wrote:
>> So far as unobfuscated versions go, how about the simple:
>> 
>> def to_bin(x):
>>   out = []
>>   while x > 0:
>>     out.insert(0, str(x % 2))
>>     x = x / 2
>>   return ''.join(out)
>> 
>> Regards,

It was surprising that

>>> i = int("111010101", 2)

is a one-way operation.

>>> s = str(i, 2)
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
TypeError: str() takes at most 1 argument (2 given)

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

Reply via email to