fork download
  1. def writer():
  2. item = yield
  3. print('Writing headers for "%s"' % item)
  4.  
  5. while True:
  6. print("Writing:", item)
  7. item = yield
  8.  
  9. w = writer()
  10. next(w) # init
  11.  
  12. w.send("First item")
  13. w.send("Second item")
  14. w.send("Third item")
  15.  
Success #stdin #stdout 0.02s 8736KB
stdin
Standard input is empty
stdout
Writing headers for "First item"
Writing: First item
Writing: Second item
Writing: Third item