damccorm commented on code in PR #34912: URL: https://github.com/apache/beam/pull/34912#discussion_r2105241495
########## website/www/site/content/en/documentation/programming-guide.md: ########## @@ -1184,6 +1184,101 @@ func init() { </span> +{{< paragraph class="language-python">}} +Proper Use of return vs yield in Python Functions. +{{< /paragraph >}} + +{{< highlight python >}} +# Returning a single string instead of a sequence +class ReturnIndividualElement(beam.DoFn): + def process(self, element): + return element + +with beam.Pipeline() as pipeline: + ( + pipeline + | "CreateExamples" >> beam.Create(["foo"]) + | "MapIncorrect" >> beam.ParDo(ReturnIndividualElement()) + | "Print" >> beam.Map(print) + ) + # prints: + # f + # o + # o +{{< /highlight >}} + +<span class="language-python"> + +> **Returning a single element (e.g., `return element`) is incorrect** Review Comment: Could you please flip the order of the descriptions and the examples? Otherwise, I worry people will just read the example and follow it without seeing the description saying it is wrong ########## website/www/site/content/en/documentation/programming-guide.md: ########## @@ -1184,6 +1184,101 @@ func init() { </span> +{{< paragraph class="language-python">}} +Proper Use of return vs yield in Python Functions. Review Comment: ```suggestion Proper use of return vs yield in Python Functions. ``` -- 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