Moving average of a data series
ema uses series in one place, where it references series[bar]. But bar is a global variable which is frowned upon. Let's pass series[bar] instead of series to ema.
That would be series[bar] in the for loop, but series[bar] is the same thing as close, so let's pass that instead.
ema's period is only used to calculate smoothing. Let's calculate smoothing outside and pass it in.
But now ema's a single line, so let's inline it
Let's put all of that logic inside a function
We use enumerate in the for loop, but we don't use bar


Result:

x = [32.47, 32.70, 32.77, 33.11, 33.25, 33.23, 33.23, 33.0, 33.04, 33.21]

def function(x, period):
    prevema = x[0] 
    emaout =[]

    smoothing = 2.0 / (period + 1.0)                
    for close in x:
        curema = prevma + smoothing * (close - prevma) 
        prevema = curema
        emaout.append(curema)

    return prevema
print 
print function(x, 5)


We can better by using numpy. 

def function(x, period):
    smoothing = 2.0 / (period + 1.0)                
    current = numpy.array(x) # take the current value as a numpy array

    previous = numpy.roll(x,1) # create a new array with all the values shifted forward
    previous[0] = x[0] # start with this exact value
    # roll will have moved the end into the beginning not what we want

    return previous + smoothing * (current - previous)