Skip to content

Instantly share code, notes, and snippets.

@kunigami

kunigami/subroutine.py

Last active Feb 1, 2020
Embed
What would you like to do?
def add(x, y):
yield x + y
def main():
result = yield add(2, 2)
print(result)
yield
main_cr = main()
# add() is not executed
add_cr = main_cr.send(None)
# it has to be explicitly executed
result = add_cr.send(None)
main_cr.send(result)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.