def bits(s, e, byte):
    """
    Extract bits start, end, byte
    Ex. bits(4,2,27) == 0b110 (extracting bits 4, 3 and 2)
    """
    byte = byte>>e
    return byte & [1, 3, 7, 15, 31, 63, 127, 255][s-e]