/yield-from

A backport of Python 3's "yield from" to Python 2.7.

Primary LanguagePythonMIT LicenseMIT

yield-from

PyPI version Liberapay receiving

A backport of yield from from Python 3 to Python 2.7.

For more information, see https://github.com/hchasestevens/hchasestevens.github.io/blob/master/notebooks/backporting-yield-from-to-python-27.ipynb

Installation

pip install yield-from

Usage

>>> from yieldfrom import yield_from, rewrite_yield_from
>>> def inner():
...   yield 'inner'
...
>>> @rewrite_yield_from
... def outer():
...   yield 'outer start'
...   yield_from(inner())
...   yield 'outer end'
...
>>> list(outer())
['outer start', 'inner', 'outer end']

Contacts