Created
February 27, 2014 20:24
-
-
Save kojiromike/9258780 to your computer and use it in GitHub Desktop.
This file contains 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
from collections import deque | |
last3 = deque(maxlen=3) | |
def pings(): | |
while True: | |
yield timepassed() * 17000 # Assume timepassed is updated somehow | |
# This may seem not D.R.Y., but there are only three… | |
ping = next(pings) # ;) Who knows how the pings are gotten | |
print("Current average: " + ping) # avg = ping/1 | |
last3.append(ping) | |
last3.append(next(pings)) | |
print("Current average: " + sum(last3) / 2) | |
while True: | |
last3.append(next(pings)) | |
print("Current average: " + sum(last3) / 3) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment