def simple_moving_average(iterable, k=10):
 a = (iterable if isinstance(iterable, list) else list(iterable))
 for m in xrange(len(a)):
  i = (m - k)
  j = ((m + k) + 1)
  w = a[max(0, i):j]
  (yield (float(sum(w)) / (len(w) or 1)))

def simple_moving_average ( iterable , k = 10 ) : a = ( iterable if isinstance ( iterable , list ) else list ( iterable ) ) for m in xrange ( len ( a ) ) : i = ( m - k ) j = ( ( m + k ) + 1 ) w = a [ max ( 0 , i ) : j ] ( yield ( float ( sum ( w ) ) / ( len ( w ) or 1 ) ) )
returns an iterator over the simple moving average of the given list of values .