Created
April 17, 2015 10:41
-
-
Save nikalras/6cca51c1aad87e077568 to your computer and use it in GitHub Desktop.
generator
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 accumulator(sum): | |
while True: | |
sum += yield sum | |
x = accumulator(1) | |
x.send(None) | |
x.send(5) | |
print(accumulator(3)) | |
print(x.send(2.3)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment