Guest User

Untitled

a guest
Jan 18th, 2019
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.23 KB | None | 0 0
  1. def gen():
  2. for i in range(10):
  3. X = yield i
  4. if X == 'stop':
  5. break
  6. print("Inside the function " + str(X))
  7.  
  8. m = gen()
  9. print("1 Outside the function " + str(next(m)) + 'n')
  10. print("2 Outside the function " + str(next(m)) + 'n')
  11. print("3 Outside the function " + str(next(m)) + 'n')
  12. print("4 Outside the function " + str(next(m)) + 'n')
  13. print('n')
  14. print("Outside the function " + str(m.send(None)) + 'n') # Start generator
  15. print("Outside the function " + str(m.send(77)) + 'n')
  16. print("Outside the function " + str(m.send(88)) + 'n')
  17. #print("Outside the function " + str(m.send('stop')) + 'n')
  18. print("Outside the function " + str(m.send(99)) + 'n')
  19. print("Outside the function " + str(m.send(None)) + 'n')
  20.  
  21. 1 Outside the function 0
  22.  
  23. Inside the function None
  24. 2 Outside the function 1
  25.  
  26. Inside the function None
  27. 3 Outside the function 2
  28.  
  29. Inside the function None
  30. 4 Outside the function 3
  31.  
  32.  
  33.  
  34. Inside the function None
  35. Outside the function 4
  36.  
  37. Inside the function 77
  38. Outside the function 5
  39.  
  40. Inside the function 88
  41. Outside the function 6
  42.  
  43. Inside the function 99
  44. Outside the function 7
  45.  
  46. Inside the function None
  47. Outside the function 8
  48.  
  49. R = kitchen.send("Ham omelette, side salad")
  50.  
  51. next_order = yield [HamOmelette(), SideSalad()]
Add Comment
Please, Sign In to add comment