RosettaCodeData/Task/Priority-queue/Python/priority-queue-1.py

17 lines
329 B
Python
Raw Permalink Normal View History

2013-04-10 23:57:08 -07:00
>>> import queue
>>> pq = queue.PriorityQueue()
>>> for item in ((3, "Clear drains"), (4, "Feed cat"), (5, "Make tea"), (1, "Solve RC tasks"), (2, "Tax return")):
2014-01-17 05:32:22 +00:00
pq.put(item)
2013-04-10 23:57:08 -07:00
>>> while not pq.empty():
2014-01-17 05:32:22 +00:00
print(pq.get_nowait())
2013-04-10 23:57:08 -07:00
(1, 'Solve RC tasks')
(2, 'Tax return')
(3, 'Clear drains')
(4, 'Feed cat')
(5, 'Make tea')
>>>