python-distilled
python-distilled copied to clipboard
6.6 line_receiver must be initialized with r.send(None)
Thank you for writing this book! Python Distilled is a worthy replacement for Python Essential Reference.
In section 6.6 the code snippet that demonstrates the enhanced generator line_receiver is missing the initialization step r.send(None).
In other words change
from
r = line_receiver()
r.send(b'hello')
r.send(b'world\nit ')
r.send(b'works!')
r.send(b'\n')
to
r = line_receiver()
r.send(None) # Missing in book.
r.send(b'hello')
r.send(b'world\nit ')
r.send(b'works!')
r.send(b'\n')