On 3/2/07, Jim Jewett email@example.com wrote:
On 3/1/07, Adam Olsen firstname.lastname@example.org wrote:
On 3/1/07, Jason Orendorff email@example.com wrote:
Should inherit from object if this is going into 2.x.
def __init__(self, elements=(), *, cmp=None, key=None, reversed=False) def add(self, element) def pop(self) --> remove and return the min element def __iter__(self) --> (while self: yield self.pop())
__iter__ shouldn't modify the container.
generators do not need to be reiterable.
lists are reiterable, but I wouldn't expect a socket (treated as a file) to be.
For a queue that is already sorted, the natural use case is to take the task and do it, explicitly adding it back to the end if need be. I would expect an operation that *didn't* remove things from the queue to have view in the name somewhere.
I would be incredibly surprised if
for x in queue: ....
destroyed the queue. __iter__ should be implemented non-destructively.