hexDict = {
'0':'0000', '1':'0001', '2':'0010', '3':'0011', '4':'0100', '5':'0101',
'6':'0110', '7':'0111', '8':'1000', '9':'1001', 'a':'1010', 'b':'1011',
'c':'1100', 'd':'1101', 'e':'1110', 'f':'1111', 'L':''}
def dec2bin(n):
"""
A foolishly simple look-up method of getting binary string from an integer
This happens to be faster than all other ways!!!
"""
# =========================================================
# create hex of int, remove '0x'. now for each hex char,
# look up binary string, append in list and join at the end.
# =========================================================
return ''.join([hexDict[hstr] for hstr in hex(n)[2:]])