Want to get the minimal elements for a min heap in Python using heapq, here is my code and wondering if using h[0] is the correct way or a more elegant public API for heapq? I tried to find is there is an API to get minimal element of a heap, but cannot find it out.
BTW, using Python 2.
import heapq
def heapMin(iterable):
h = []
for value in iterable:
heapq.heappush(h, value)
return h[0]
if __name__ == "__main__":
print heapMin([1, 3, 5, 7, 9, 2, 4, 6, 8, 0])
thanks in advance, Lin