implement 'util.unique_squence()'
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
# Copyright 2017-2020 Mike Fährmann
|
||||
# Copyright 2017-2021 Mike Fährmann
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License version 2 as
|
||||
@@ -65,6 +65,15 @@ def unique(iterable):
|
||||
yield element
|
||||
|
||||
|
||||
def unique_sequence(iterable):
|
||||
"""Yield sequentially unique elements from 'iterable'"""
|
||||
last = None
|
||||
for element in iterable:
|
||||
if element != last:
|
||||
last = element
|
||||
yield element
|
||||
|
||||
|
||||
def raises(cls):
|
||||
"""Returns a function that raises 'cls' as exception"""
|
||||
def wrap(*args):
|
||||
|
||||
Reference in New Issue
Block a user