Re: Name bindings for inner functions.

2006-10-28 Thread trevor_morgan
Thanks, that's exactly what I needed. Andrea Griffini wrote: > [EMAIL PROTECTED] wrote: > > The following code: > > > > def functions(): > > l=list() > > for i in range(5): > > def inner(): > > return i > > l.append(inner) > > return l > > > > > > print [f()

Name bindings for inner functions.

2006-10-28 Thread trevor_morgan
The following code: def functions(): l=list() for i in range(5): def inner(): return i l.append(inner) return l print [f() for f in functions()] returns [4,4,4,4,4], rather than the hoped for [0,1,2,3,4]. I presume this is something to do with the varia