Constructs an iterable which intertwines given iterables.

    The resulting iterable will return an item from first sequence,
    then from second, etc. until the last one - and then another item from
    first, then from second, etc. - up until all iterables are exhausted.

def intertwine(*iterables):
    """Constructs an iterable which intertwines given iterables.

    The resulting iterable will return an item from first sequence,
    then from second, etc. until the last one - and then another item from
    first, then from second, etc. - up until all iterables are exhausted.
    """
    iterables = tuple(imap(ensure_iterable, iterables))

    empty = object()
    return (item
            for iterable in izip_longest(*iterables, fillvalue=empty)
            for item in iterable if item is not empty)