Skip to content

Instantly share code, notes, and snippets.

@vsmelov
Created November 6, 2017 18:58
Show Gist options
  • Save vsmelov/6edc331a60dfe53acc6589532998af3b to your computer and use it in GitHub Desktop.
Save vsmelov/6edc331a60dfe53acc6589532998af3b to your computer and use it in GitHub Desktop.
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