heapq.heappush and pop to use key

jm.suresh@no.spam.gmail.com jm.suresh at gmail.com
Fri Mar 9 00:40:29 EST 2007


On Mar 8, 9:02 pm, Marc 'BlackJack' Rintsch <bj_... at gmx.net> wrote:
> In <1173364305.281085.271... at t69g2000cwt.googlegroups.com>,
>
> jm.sur... at no.spam.gmail.com wrote:
> > I wanted to have a heap of custom objects, and in different heaps I
> > wanted to have the weights for my elements differently. So, I modified
> > the heapq module to accept key arguments also.
>
> I would have just used tuples of the form (weight, obj) with the original
> `heapq` module.
>
> Ciao,
>         Marc 'BlackJack' Rintsch

Thanks. I will go with tuples itself.
-
Suresh




More information about the Python-list mailing list