[New-bugs-announce] [issue16150] Implement generator interface in itertools.chain.

pyos report at bugs.python.org
Sat Oct 6 16:52:28 CEST 2012


New submission from pyos:

Since "yield from" made it into Python 3.3, I think it would be useful to chain multiple generators and still get a generator, not an iterator. That is, the following code:

def f():
    yield from itertools.chain(A, B, C)

should be (at least roughly) equivalent to

def f():
    yield from A
    yield from B
    yield from C

while still allowing to send() values to whichever subgenerator is currently running or throw() exceptions inside them.

The attached patch adds this functionality to itertools.chain objects.

----------
components: Extension Modules
files: itertools-chain-send-throw-and-close.diff
keywords: patch
messages: 172204
nosy: pyos, rhettinger
priority: normal
severity: normal
status: open
title: Implement generator interface in itertools.chain.
versions: Python 3.3, Python 3.4, Python 3.5
Added file: http://bugs.python.org/file27455/itertools-chain-send-throw-and-close.diff

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue16150>
_______________________________________


More information about the New-bugs-announce mailing list