book-site icon indicating copy to clipboard operation
book-site copied to clipboard

19-coroutine/coroaverager3:grouper

Open ramalho opened this issue 4 years ago • 0 comments

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

ramalho avatar Aug 26 '21 21:08 ramalho