t292.py 294 B

123456789101112131415
  1. def mygen(upto):
  2. for i in range(0, upto):
  3. print 'i',i
  4. got = yield i
  5. print 'got',got
  6. handle = mygen(3)
  7. first = True
  8. for num in handle:
  9. print 'num',num
  10. if first:
  11. print 'signalling'
  12. foo = handle.send('sig')
  13. print 'foo', foo
  14. first = False