Skip to content

Instantly share code, notes, and snippets.

@nikalras
Created April 17, 2015 10:41
Show Gist options
  • Save nikalras/6cca51c1aad87e077568 to your computer and use it in GitHub Desktop.
Save nikalras/6cca51c1aad87e077568 to your computer and use it in GitHub Desktop.
generator
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