From: Raymond Hettinger Date: Fri, 24 Apr 2009 18:43:43 +0000 (+0000) Subject: Issue 5830: Events are now comparable when the time and type are the same. X-Git-Tag: v3.1b1~203 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=8f40e099c39084f18be980ded5521603fe68800a;p=python Issue 5830: Events are now comparable when the time and type are the same. --- 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):