Want more features on Pastebin? Sign Up, it's FREE!
Guest

Untitled

By: a guest on Sep 7th, 2012  |  syntax: Python  |  size: 0.29 KB  |  views: 22  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. >>> gen = ((yield)+(yield) for _ in range(2))
  2. >>> gen.next()
  3. >>> gen.send(100)
  4. >>> gen.send(200)
  5. 300
  6. >>> gen.next()
  7. >>> gen.send(500)
  8. >>> gen.send(120)
  9. 620
  10. >>> gen.next()
  11.  
  12. Traceback (most recent call last):
  13.   File "<pyshell#113>", line 1, in <module>
  14.     gen.next()
  15. StopIteration
  16. >>>
clone this paste RAW Paste Data