In message <[EMAIL PROTECTED]>, [EMAIL PROTECTED] wrote:

> Mirco Wahab:
>> But where is the %b in Python?
> 
> Python doesn't have that. You can convert the number to a hex, and then
> map the hex digitds to binary strings using a dictionary, like this:
> http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/440528

How about this: (where n is the integer you want to convert):

    "".join([["0", "1"][(1 << i & n) != 0] for i in 
range(int(math.ceil(math.log(n, 2))) - 1, -1, -1)])

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

Reply via email to