updated from atlas

This commit is contained in:
Luciano Ramalho
2015-02-20 14:33:00 -02:00
parent e910ec5458
commit 304d628066
4 changed files with 56 additions and 25 deletions

View File

@@ -4,7 +4,6 @@ A coroutine to compute a running average
>>> coro_avg = averager() # <1>
>>> next(coro_avg) # <2>
0.0
>>> coro_avg.send(10) # <3>
10.0
>>> coro_avg.send(30)
@@ -15,8 +14,9 @@ A coroutine to compute a running average
"""
def averager():
total = average = 0.0
total = 0.0
count = 0
average = None
while True:
term = yield average # <4>
total += term