Are there any canned Python methods to convert an Integer (or Long) into a binary string in Python?
There are a myriad of dec2bin() functions out on Google... But I
here is simple solution using the divmod() fucntion which returns the reminder and the result of a division without the fraction.
def dectobin(number): bin = '' while (number >= 1): number, rem = divmod(number, 2) bin = bin + str(rem) return bin