code: def average(var, key, N):
      '''average over N points'''
      global average_data
      if not key in average_data:
          average_data[key] = [var]*N
          return var
      average_data[key].pop(0)
      average_data[key].append(var)
      return sum(average_data[key])/f average(var, key, N):
      '''average over N points'''
      global average_data
      if not key in average_data:
          average_data[key] = [var]*N
          return var
      average_data[key].pop(0)
      average_data[key].append(var)
      return sum(average_data[key])/N
docs: average over N points