python-distilled
python-distilled copied to clipboard
Undefined decorator
On pages 474-475, the consumer decorator is not defined.
@consumer
def line_receiver():
data = bytearray()
line = None
linecount = 0
while True:
part = yield line
linecount += part.count(b'\n')
data.extend(part)
if linecount > 0:
index = data.index(b'\n')
line = bytes(data[:index+1])
data = data[index+1:]
linecount -= 1
else:
line = None
r = line_receiver()
r.send(b'Hello')