From c3bed8df3647d16772d7bf060c1ef988d2fb1cba Mon Sep 17 00:00:00 2001 From: Skyler Lehmkuhl Date: Thu, 28 Nov 2013 01:22:38 -0500 Subject: [PATCH] Added function to step in pairs --- misc_funcs.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/misc_funcs.py b/misc_funcs.py index bd422b3..fa301ce 100644 --- a/misc_funcs.py +++ b/misc_funcs.py @@ -5,6 +5,7 @@ import svlgui from threading import Event, Thread +from itertools import tee, izip import math import subprocess import re @@ -258,3 +259,10 @@ class RepeatTimer(Thread): def cancel(self): self.finished.set() + + +def pairwise(iterable): + "s -> (s0,s1), (s1,s2), (s2, s3), ..." + a, b = tee(iterable) + next(b, None) + return izip(a, b)