def bits(x, n=8):
    """Convert an int into a bit sequence.

                              0  1  2  3  4  5  6  7
    >>> assert bits(0x00) == [0, 0, 0, 0, 0, 0, 0, 0]
    >>> assert bits(0x01) == [1, 0, 0, 0, 0, 0, 0, 0]
    >>> assert bits(0x10) == [0, 0, 0, 0, 1, 0, 0, 0]
    >>> assert bits(0xff) == [1, 1, 1, 1, 1, 1, 1, 1]

    The 0bXXXXXXXX format is reverse of the bit sequence
    >>> assert bits(0b00000000) == [0, 0, 0, 0, 0, 0, 0, 0]
    >>> assert bits(0b00000001) == [1, 0, 0, 0, 0, 0, 0, 0]
    >>> assert bits(0b00010000) == [0, 0, 0, 0, 1, 0, 0, 0]
    >>> assert bits(0b11111111) == [1, 1, 1, 1, 1, 1, 1, 1]

    If the number doesn't fit, raise an error
    >>> bits(0x100)
    Traceback (most recent call last):
        ...
    AssertionError
    """
    assert isinstance(x, int)
    blist = [int(bit) for bit in reversed("{0:0{n}b}".format(x, n=n))]
    assert len(blist) == n
    return blist