python-distilled icon indicating copy to clipboard operation
python-distilled copied to clipboard

Undefined decorator

Open tudor38 opened this issue 1 year ago • 0 comments

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')

tudor38 avatar Jun 06 '24 10:06 tudor38