def is_ntuple(L, *types):
    """
    Checks whether the object L is an n-element tuple throughout.
    """
    if isinstance(L, (list, tuple)):
        if len(L) == len(types):
            for elem, t in zip(L, types):
                if not isinstance(elem, t):
                    raise TypeError("'L' element {} is not of type {}".
                        format(elem, t))
        else:
            raise ValueError('L must be the same length as type list')
    else:
        raise TypeError("'L' must be of type [list, tuple]")
