Skip to content

Instantly share code, notes, and snippets.

@taojy123
Created July 24, 2020 14:21
Show Gist options
  • Save taojy123/a39fc70fc8df5055a8adfe52454e14f0 to your computer and use it in GitHub Desktop.
Save taojy123/a39fc70fc8df5055a8adfe52454e14f0 to your computer and use it in GitHub Desktop.
# =========================
def ff():
for i in range(4):
a = yield i
print('a:', a)
def gg():
yield from ff()
def hh():
yield from gg()
f = hh()
print(f.send(None))
print(f.send(9))
print(f.send(8))
# ff == gg == hh
# =========================
def xx():
# l = yield from sub_coro()
# equals to ==>
s = sub_coro()
v = None
while True:
try:
t = s.send(v)
v = yield t
except StopIteration as e:
l = e.value
break
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment