Robots Atlas>ROBOTS ATLAS

Python โ€” From Basics to Advanced ยท Generators and Iterators

yield from and Delegation

Generators and Iterators

Introduction

yield from (Python 3.3+, PEP 380) delegates iteration to another iterable or generator. Instead of writing "for x in inner: yield x" you write "yield from inner". For sub-generators it is full delegation: send/throw/close are forwarded, and the sub-generator return value becomes the value of the yield from expression.