On Sep 4, 2:51 pm, Martin DeMello <[EMAIL PROTECTED]> wrote: > On Sep 4, 12:41 pm, Fredrik Lundh <[EMAIL PROTECTED]> wrote: > > > "task_done" just decrements a counter (incremented by "put"). when the > > counter reaches zero, the "join" call is unblocked. > > Thanks! Is there any standard python idiom to empty a queue into a > list? Or do I just call get() repeatedly and catch the exception when > it's done? > > martin
Random access isn't supported by the defined interface. You can make it more convenient, though. import Queue class IterQueue( Queue.Queue ): def __iter__( self ): return self def next( self ): if self.empty(): raise StopIteration return self.get() q= IterQueue() q.put( 'a' ) q.put( 'b' ) q.put( 'c' ) print [ x for x in q ] /Output: ['a', 'b', 'c'] -- http://mail.python.org/mailman/listinfo/python-list