Interview Prep/Python for DevOps/Language essentials & functions

What does `yield from` do?

AdvancedConceptLanguage essentials & functions
Answer

yield from iterable yields every item of a sub-iterable, and for sub-generators it also forwards send(), throw() and close() and returns the sub-generator's return value. In everyday DevOps code it is simply the clean way to flatten: yield from page["Reservations"] instead of a nested for with yield. It is also how generator-based coroutines were built before async/await.

All Python for DevOps questions Roadmap: Python for automation

More on Language essentials & functions