[New-bugs-announce] [issue41339] make queue.Queue objects iterable

Alan Iwi report at bugs.python.org
Sun Jul 19 06:03:55 EDT 2020


New submission from Alan Iwi <alan.iwi at stfc.ac.uk>:

It is possible to make `queue.Queue` and `queue.SimpleQueue` objects iterable by adding simple `__iter__` and `__next__` methods.  This is to suggest adding these methods to the existing `Queue` and `SimpleQueue` so that they are iterable by default.

```
class Fifo(SimpleQueue):

    def __iter__(self):
        return self

    def __next__(self):
        if not self.empty():
            return self.get()
        raise StopIteration
```

----------
components: Library (Lib)
messages: 373950
nosy: alaniwi
priority: normal
severity: normal
status: open
title: make queue.Queue objects iterable
type: enhancement

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue41339>
_______________________________________


More information about the New-bugs-announce mailing list