First of all, congratulations for the awesome example of Game of Life using coroutines and yield from. It's the most interesting example of yield from outside of the asyncio context I've found.
A nit pick, in Item 40, ex. 7, you have this snippet:
try:
count = it.send(EMPTY) # Send q8 state, retrieve count
except StopIteration as e:
print('Count: ', e.value) # Value from return statement
This code does display the count, but the assignment inside the try clause never actually happens. Some of your readers may be misled by this, and the comment in the same line reinforces the potential misunderstanding.
I'd rewrite it along these lines:
try:
it.send(EMPTY) # Send q8 state, driving the coroutine to end
except StopIteration as e:
count = e.value # Value from return statement
print('Count: ', count)
This is a tiny detail, otherwise the example and your explanations in the book are outstanding!
Cheers!
First of all, congratulations for the awesome example of Game of Life using coroutines and yield from. It's the most interesting example of yield from outside of the asyncio context I've found.
A nit pick, in Item 40, ex. 7, you have this snippet:
This code does display the count, but the assignment inside the
tryclause never actually happens. Some of your readers may be misled by this, and the comment in the same line reinforces the potential misunderstanding.I'd rewrite it along these lines:
This is a tiny detail, otherwise the example and your explanations in the book are outstanding!
Cheers!