[Python-ideas] `__iter__` for queues?

cool-RR cool-rr at cool-rr.com
Thu Jan 21 00:09:06 CET 2010


Okay Raymond. Thanks for your patience.

Ram.

On Thu, Jan 21, 2010 at 12:48 AM, Raymond Hettinger <
raymond.hettinger at gmail.com> wrote:

>
> On Jan 20, 2010, at 12:28 PM, cool-RR wrote:
>
> > Thanks for the code Raymond. However, what I use is actually simpler:
> >
> > def iterate(queue, block=False):
> >     '''Iterate over the items in the queue.'''
> >     while True:
> >         try:
> >             yield queue.get(block=block)
> >         except Queue.Empty:
> >             raise StopIteration
>
> Then it sounds like the existing API is more than adequate for your needs.
> Dump the above fragment in your utils module and be done with it.
>
>
> Raymond
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20100121/2c01bd19/attachment.html>


More information about the Python-ideas mailing list