Commits

Jason R. Coombs committed 287dacd

Use setdefault for assigning handlers

Comments (0)

Files changed (1)

         number is highest priority).  If a handler function returns
         "NO MORE", no more handlers will be called.
         """
-        if not event in self.handlers:
-            self.handlers[event] = []
-        bisect.insort(self.handlers[event], ((priority, handler)))
+        event_handlers = self.handlers.setdefault(event, [])
+        bisect.insort(event_handlers, (priority, handler))
 
     def remove_global_handler(self, event, handler):
         """Removes a global handler function.