pop element from heap : heapq « Buildin Module « Python Tutorial






from heapq import *
from random import shuffle
data = range(10)
shuffle(data)
heap = []
for n in data:
   heappush(heap, n)
   
print heappop(heap)
print heappop(heap)
print heappop(heap)
print heap








14.6.heapq
14.6.1.heap is a kind of priority queue.
14.6.2.pop element from heap