Selects a subsequence of given tuple, including only specified indices.

    :param indices: Iterable of indices to include
    :param strict: Whether ``indices`` are required to exist in the tuple.

    :return: Tuple with selected elements, in the order corresponding
             to the order of ``indices``.

    :raise IndexError: If ``strict`` is True and one of ``indices``
                       is out of range.

def select(indices, from_, strict=False):
    """Selects a subsequence of given tuple, including only specified indices.

    :param indices: Iterable of indices to include
    :param strict: Whether ``indices`` are required to exist in the tuple.

    :return: Tuple with selected elements, in the order corresponding
             to the order of ``indices``.

    :raise IndexError: If ``strict`` is True and one of ``indices``
                       is out of range.
    """
    ensure_iterable(indices)
    ensure_sequence(from_)

    if strict:
        return from_.__class__(from_[index] for index in indices)
    else:
        len_ = len(from_)
        return from_.__class__(from_[index] for index in indices
                               if 0 <= index < len_)