updated from atlas
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user