book-site
book-site copied to clipboard
19-coroutine/coroaverager3:grouper
Issue originally reported by @dongzeXD at https://github.com/fluentpython/example-code-2e/issues/15, related to an example in post Classic Coroutines:
In <6> annotations :"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."
Would I replace while True with yield?
This seems easier to understand