Skip to content

Commit d9321d8

Browse files
authored
Recommend yield from for emitting elements from iterables. (#25893)
1 parent 915da25 commit d9321d8

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

website/www/site/content/en/documentation/programming-guide.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -955,9 +955,10 @@ the actual processing logic. You don't need to manually extract the elements
955955
from the input collection; the Beam SDKs handle that for you. Your `process` method
956956
should accept an argument `element`, which is the input element, and return an
957957
iterable with its output values. You can accomplish this by emitting individual
958-
elements with `yield` statements. You can also use a `return` statement
959-
with an iterable, like a list or a generator. Don't mix `yield` and
960-
`return` statements in the same `process` method - this leads to [undefined behavior](https://github.com/apache/beam/issues/22969).
958+
elements with `yield` statements, and use `yield from` to emit all elements from
959+
an iterable, such as a list or a generator. Using `return` statement
960+
with an iterable is also acceptable as long as you don't mix `yield` and
961+
`return` statements in the same `process` method, since that leads to [incorrect behavior](https://github.com/apache/beam/issues/22969).
961962
{{< /paragraph >}}
962963

963964
{{< paragraph class="language-go">}}

0 commit comments

Comments
 (0)