damccorm commented on code in PR #34912: URL: https://github.com/apache/beam/pull/34912#discussion_r2162327101
########## website/www/site/content/en/documentation/programming-guide.md: ########## @@ -1183,6 +1183,100 @@ func init() { > parameters to a single `emitter function`. </span> +{{< paragraph class="language-python">}} +Proper use of return vs yield in Python Functions. +{{< /paragraph >}} + +<span class="language-python"> + +> **Returning a single element (e.g., `return element`) is incorrect** +> The `process` method in Beam must return an *iterable* of elements. Returning a single value like an integer or string +> (e.g., `return element`) leads to a runtime error (`TypeError: 'int' object is not iterable`) or incorrect results since the return value +> will be treated as an iterable. Always ensure your return type is iterable. + +</span> + +{{< highlight python >}} +# Returning a single string instead of a sequence Review Comment: ```suggestion # Incorrectly returning a single string instead of a sequence ``` Maybe helpful to add this too -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: github-unsubscr...@beam.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org