Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def gen():
- for i in range(10):
- X = yield i
- if X == 'stop':
- break
- print("Inside the function " + str(X))
- m = gen()
- print("1 Outside the function " + str(next(m)) + 'n')
- print("2 Outside the function " + str(next(m)) + 'n')
- print("3 Outside the function " + str(next(m)) + 'n')
- print("4 Outside the function " + str(next(m)) + 'n')
- print('n')
- print("Outside the function " + str(m.send(None)) + 'n') # Start generator
- print("Outside the function " + str(m.send(77)) + 'n')
- print("Outside the function " + str(m.send(88)) + 'n')
- #print("Outside the function " + str(m.send('stop')) + 'n')
- print("Outside the function " + str(m.send(99)) + 'n')
- print("Outside the function " + str(m.send(None)) + 'n')
- 1 Outside the function 0
- Inside the function None
- 2 Outside the function 1
- Inside the function None
- 3 Outside the function 2
- Inside the function None
- 4 Outside the function 3
- Inside the function None
- Outside the function 4
- Inside the function 77
- Outside the function 5
- Inside the function 88
- Outside the function 6
- Inside the function 99
- Outside the function 7
- Inside the function None
- Outside the function 8
- R = kitchen.send("Ham omelette, side salad")
- next_order = yield [HamOmelette(), SideSalad()]
Add Comment
Please, Sign In to add comment