Created
July 24, 2020 14:21
-
-
Save taojy123/a39fc70fc8df5055a8adfe52454e14f0 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 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