def bin_to_int(bin_list, inverse=True):
    """ Given arbitrary length list of binary values, calculate integer value.

    Parameters
    ----------
    bin_list : list of int
        List of binary values for calculating integer value.
    inverse : bool, optional
        If true (default) caluclate integer from bin_list assuming first element
        is LSB. If false, integer will be calculated from bin_list assuming first
        element is MSB.

    Returns
    -------
    int
        Integer value calculated from bin_list.
    """
    if inverse:
        step = -1
    else:
        step = 1
    bin_list = bin_list[::step]
    bin_int = 0
    for bit in bin_list:
        bin_int = (bin_int << 1) | bit
    return int(bin_int)