def unique(iterable, key=identity):
    """Yields all the unique values in an iterable maintaining order"""
    seen = set()
    for item in iterable:
        item_key = key(item)
        if item_key not in seen:
            seen.add(item_key)
            yield item
def unique ( iterable , key = identity ) : seen = set ( ) for item in iterable : item_key = key ( item ) if item_key not in seen : seen . add ( item_key ) yield item
Yields all the unique values in an iterable maintaining order