def writer():
item = yield
print('Writing headers for "%s"' % item)
while True:
print("Writing:", item)
item = yield
w = writer()
next(w) # init
w.send("First item")
w.send("Second item")
w.send("Third item")
ZGVmIHdyaXRlcigpOgoJaXRlbSA9IHlpZWxkCglwcmludCgnV3JpdGluZyBoZWFkZXJzIGZvciAiJXMiJyAlIGl0ZW0pCgkKCXdoaWxlIFRydWU6CgkJcHJpbnQoIldyaXRpbmc6IiwgaXRlbSkKCQlpdGVtID0geWllbGQKCncgPSB3cml0ZXIoKQpuZXh0KHcpICAjIGluaXQKCncuc2VuZCgiRmlyc3QgaXRlbSIpCncuc2VuZCgiU2Vjb25kIGl0ZW0iKQp3LnNlbmQoIlRoaXJkIGl0ZW0iKQo=