From 0b3d162a8e59e61d648b14ba00f52fe2d335d776 Mon Sep 17 00:00:00 2001 From: Benjamin Bertrand Date: Sat, 26 Mar 2016 05:37:51 +0300 Subject: [PATCH] add new setting for no_repetition decorator --- pymath/calculus/decorators.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/pymath/calculus/decorators.py b/pymath/calculus/decorators.py index 2773582..4763ae7 100644 --- a/pymath/calculus/decorators.py +++ b/pymath/calculus/decorators.py @@ -3,10 +3,11 @@ from functools import wraps -def no_repetition(equals=lambda x,y: x == y): +def no_repetition(equals=lambda x,y: x == y, old = ""): """ Remove yield values which has already been yield - :param fun: a generator + :param equals: test for equality + :param old: initiate form of data. :returns: same generator with no repetitions >>> norep = no_repetition() @@ -22,7 +23,7 @@ def no_repetition(equals=lambda x,y: x == y): @wraps(fun) def dont_repeat(*args, **kwrds): gen = fun(*args, **kwrds) - old_s = "" + old_s = old while True: try: new_s = next(gen)