A robust implementation of ``yield from`` behavior.
Project description
A robust implementation of yield from behavior. Good for transpilers, backpilers, and code that needs to be portable to minimal or old Pythons.
This implementation avoids the complexity and overheads of typical yield from backports - the tradeoff is that it is less obvious and does not resemble yield from syntax.
Versioning
This library’s version numbers follow the SemVer 2.0.0 specification.
Installation
pip install yield-from-as-an-iterator
Usage
Import yield_from:
from yieldfrom import yield_from
Replace yield from ... with:
for value, handle_send, handle_throw in yield_from(...):
try:
handle_send(yield value)
except:
if not handle_throw(*sys.exc_info()):
raise
Portability
Portable to all releases of Python 3, and releases of Python 2 starting with 2.5.
On Pythons older than 2.5, or on any other Python that doesn’t implement PEP-342:
This will still import without errors.
The functions will execute correctly if GeneratorExit is polyfilled.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for yield-from-as-an-iterator-1.0.0.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 38c0432c2565fae3f50dada871534e6f8a8c3178bcfb1cb8498061cec0d7f769 |
|
MD5 | 453a80ac5a36037d6a7fb27dcff51769 |
|
BLAKE2b-256 | f80494e6c1be4c279a2a9ae37d13cd2be59515d373441f9c5b9f36e677e6e894 |
Hashes for yield_from_as_an_iterator-1.0.0-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ded245ae0350d75642d927d20dd8e2517a6fa753852358d98f4247df3d65efd4 |
|
MD5 | fa956188d492cc8e243cce536b559eb9 |
|
BLAKE2b-256 | b6ed3c311012029c210c983ab734b1fde6703c4027dc754bea8f3b04892f1820 |