def triplets(iterable):
    """
    >>> list(triplets([1,2,3,4,5]))
    [(1, 2, 3), (2, 3, 4), (3, 4, 5)]
    """
    iterable = iter(iterable)
    backlog = next(iterable), next(iterable)
    for item in iterable:
        yield backlog[0], backlog[1], item
        backlog = backlog[1], item
