fluentpython / example-code-2e

Example code for Fluent Python, 2nd edition (O'Reilly 2022)
https://amzn.to/3J48u2J
MIT License
3.26k stars 919 forks source link

modify 19-coroutine/coroaverager3:grouper #14

Closed dongzeXD closed 3 years ago

dongzeXD commented 3 years ago

In annotations <6>:"Each iteration in thisloop creates a new instance of averager; each is a generator object operating as a coroutine." and <7>:"Whenever grouper is sent a value, it’s piped ..., the value it returns is bound to results[key]. The while loop then proceeds to create another averager instance to consume more values." This two annotations and while True loop will misguide noob readers(like me) to a certain degree. It would be better to replace while True with yield. Please info me if I get something wrong. Thanks for your coding.