def iter_last(iterable):
    """
    For processing the last element differently
    Yields: (is_last=bool, element)
    """
    length = len(iterable)
    return ((i == length-1, x) for i, x in enumerate(iterable))

    For processing the last element differently
    Yields: (is_last=bool, element)
    
surreal/utils/common.py