Convert greycode to binary

def gray2int(graystr):
    """Convert greycode to binary"""
    num = bin2int(graystr)
    num ^= (num >> 8)
    num ^= (num >> 4)
    num ^= (num >> 2)
    num ^= (num >> 1)
    return num