aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/util.py6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/util.py b/src/util.py
index 0ed41f8..d9fc5e5 100644
--- a/src/util.py
+++ b/src/util.py
@@ -113,6 +113,7 @@ class Sometimes:
self.function = function
self.interval = interval
self.counter = initial
+ self.last_return = None
def __call__(self, *args, **kargs):
'''
@@ -120,11 +121,12 @@ class Sometimes:
@param args:*? The parameters of the function
@param kargs:**? The named parameters of the function
- @return :¿R?? The return value of the function, `None` if not invoked
+ @return :¿R? The return value of the function, the last return if not invoked
'''
- rc = None
+ rc = self.last_return
if self.counter == 0:
rc = self.function(*args, **kargs)
+ self.last_return = rc
self.counter = self.interval
self.counter -= 1
return rc