def append(self,data,priority): """append a new element to the queue according to its priority""" bisect.insort(self.queue,(priority,data))