A note on heapq module
Jussi Salmela
tiedon_jano at hotmail.com
Tue Jan 16 13:06:51 EST 2007
bearophileHUGS at lycos.com kirjoitti:
> I think the sort has to be simplified, otherwise it can't keep the heap
> invariant...
>
> def sort(self):
> self.h.sort()
>
> Bye,
> bearophile
>
And __repr__ should be something like this:
=========
def __repr__(self):
if self.h:
return "Heap(%s)" % self.h
else:
return "Heap()"
==========
to make it compatible with versions earlier than 2.5
Cheers,
Jussi
More information about the Python-list
mailing list