# Yield from data-structure When writing a [[Gen - Generator|generator]] based on a data-structure that need to be yielded each value at a time, the [[yield from]] is really useful. ```python # Without yield from def incremental_wait(): times = [1, 3, 5, 8, 13] for time in times: yield time # Using yield from def incremental_wait(): times = [1, 3, 5, 8, 13] yield from times ``` The question that need to be asked is: "Do we really need a [[Gen - Generator|generator]], instead of the plain data-structure. It depends on the context and usage of the [[Gen - Generator|generator]]. To be used in a for loop, it's the [[Standalone yield from]] [[Anti-Pattern|anti-pattern]], but if delayed access to values is needed with [[next]] for example, it is a great alternative. --- Bibliography: - [Title - website.com](need bibliography)