Closed dongzeXD closed 3 years ago
Thanks for reporting this.
I have moved most content about classic coroutines from the second edition to the companion web site. The former chapter 19 is now at Classic Coroutines, including the example with the issue you have reported.
Accordingly, I have recreated the issue in the site repository: https://github.com/fluentpython/book-site/issues/4.
My priority now is to finish the book, so I will not be able to analyze the issue you reported until I deliver the revised draft. Thanks.
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
withyield
? This seems easier to understand