summaryrefslogtreecommitdiff
path: root/Lib/sched.py
diff options
context:
space:
mode:
authorRaymond Hettinger <python@rcn.com>2009-04-24 18:43:43 +0000
committerRaymond Hettinger <python@rcn.com>2009-04-24 18:43:43 +0000
commit8f40e099c39084f18be980ded5521603fe68800a (patch)
treee00bd26694315087c04678fc677d67333c8fe1d6 /Lib/sched.py
parent6ab91487c446bbc39047f7d43bbf02bf18c2645b (diff)
downloadcpython-git-8f40e099c39084f18be980ded5521603fe68800a.tar.gz
Issue 5830: Events are now comparable when the time and type are the same.
Diffstat (limited to 'Lib/sched.py')
-rw-r--r--Lib/sched.py8
1 files changed, 7 insertions, 1 deletions
diff --git a/Lib/sched.py b/Lib/sched.py
index aecdb2a475..11bb0a3a18 100644
--- a/Lib/sched.py
+++ b/Lib/sched.py
@@ -33,7 +33,13 @@ from collections import namedtuple
__all__ = ["scheduler"]
-Event = namedtuple('Event', 'time, priority, action, argument')
+class Event(namedtuple('Event', 'time, priority, action, argument')):
+ def __eq__(s, o): return (s.time, s.priority) == (o.time, o.priority)
+ def __ne__(s, o): return (s.time, s.priority) != (o.time, o.priority)
+ def __lt__(s, o): return (s.time, s.priority) < (o.time, o.priority)
+ def __le__(s, o): return (s.time, s.priority) <= (o.time, o.priority)
+ def __gt__(s, o): return (s.time, s.priority) > (o.time, o.priority)
+ def __ge__(s, o): return (s.time, s.priority) >= (o.time, o.priority)
class scheduler:
def __init__(self, timefunc, delayfunc):