Created
November 6, 2017 18:58
-
-
Save vsmelov/6edc331a60dfe53acc6589532998af3b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def foo(): | |
x = 2 | |
while True: | |
print('a x: {}'.format(x)) | |
x = yield 2*x | |
print('c x: {}'.format(x)) | |
f = foo() | |
print('begin') | |
i = next(f) | |
print('0i: {}'.format(i)) | |
while True: | |
try: | |
i = f.send(i * 3) | |
except StopIteration: | |
break | |
print('1i: {}'.format(i)) | |
if i > 10000: | |
break |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment