aboutsummaryrefslogtreecommitdiffstats
path: root/src/util.py
diff options
context:
space:
mode:
authorMattias Andrée <maandree@operamail.com>2014-03-03 20:48:49 +0100
committerMattias Andrée <maandree@operamail.com>2014-03-03 20:48:49 +0100
commit9c3a9385040d6f8c09858d2aa1f308cd51e66a80 (patch)
tree7d113f945b95f0859101d01e1d91eca8b63d0020 /src/util.py
parentadd Sometimes (diff)
downloadxpybar-9c3a9385040d6f8c09858d2aa1f308cd51e66a80.tar.gz
xpybar-9c3a9385040d6f8c09858d2aa1f308cd51e66a80.tar.bz2
xpybar-9c3a9385040d6f8c09858d2aa1f308cd51e66a80.tar.xz
Sometimes returns the last return
Signed-off-by: Mattias Andrée <maandree@operamail.com>
Diffstat (limited to '')
-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