Dave Angel <da...@ieee.org> wrote: > or even better, without the extra local var: > > def pop (self): > if len(self.__heap) == 0: > raise InnerInterpreterError, "stack underflow" > return self.__heap.pop(1)
pop(1)? Anyway if would be simpler and almost certainly faster to not bother checking before the pop: def pop(self): try: return self.__heap.pop() except IndexError: raise InnerInterpreterError, "stack underflow" and if performance mattered the OP might even consider pre-binding the pop method in __init__: self.__pop = self.__heap.pop but that's probably premature optimisation. > P.S. - I'm puzzled why the OP even put this message here. There's no > question posted with it. Me too. It's a repost of something from 2004. Bizarre. -- http://mail.python.org/mailman/listinfo/python-list