def sep_inserter(iterable, sep):
    """
    Insert '' between numbers in an iterable.

    Parameters
    ----------
    iterable
    sep : str
        The string character to be inserted between adjacent numeric objects.

    Yields
    ------
    The values of *iterable* in order, with *sep* inserted where adjacent
    elements are numeric. If the first element in the input is numeric
    then *sep* will be the first value yielded.

    """
    try:
        # Get the first element. A StopIteration indicates an empty iterable.
        # Since we are controlling the types of the input, 'type' is used
        # instead of 'isinstance' for the small speed advantage it offers.
        types = (int, float, long)
        first = next(iterable)
        if type(first) in types:
            yield sep
        yield first

        # Now, check if pair of elements are both numbers. If so, add ''.
        second = next(iterable)
        if type(first) in types and type(second) in types:
            yield sep
        yield second

        # Now repeat in a loop.
        for x in iterable:
            first, second = second, x
            if type(first) in types and type(second) in types:
                yield sep
            yield second
    except StopIteration:
        # Catch StopIteration per deprecation in PEP 479:
        # "Change StopIteration handling inside generators"
        return
Insert '' between numbers in an iterable.

    Parameters
    ----------
    iterable
    sep : str
        The string character to be inserted between adjacent numeric objects.

    Yields
    ------
    The values of *iterable* in order, with *sep* inserted where adjacent
    elements are numeric. If the first element in the input is numeric
    then *sep* will be the first value yielded.