Re: Remembering the context

2010-04-29 Thread Jean-Michel Pichavant
GZ wrote: Hi All, I am looking at the following code: def fn(): def inner(x): return tbl[x] tbl={1:'A', 2:'B'} f1 = inner # I want to make a frozen copy of the values of tbl in f1 tbl={1:'C', 2:'D'} f2 = inner return (f1,f2) f1,f2 = fn() f1(1) # output C f2

Re: Remembering the context

2010-04-28 Thread Chris Rebert
On Wed, Apr 28, 2010 at 1:31 AM, GZ wrote: > I am looking at the following code: > > def fn(): > >    def inner(x): >         return tbl[x] > >    tbl={1:'A', 2:'B'} >    f1 = inner   # I want to make a frozen copy of the values of tbl > in f1 >    tbl={1:'C', 2:'D'} >    f2 = inner >   return (f1

Remembering the context

2010-04-28 Thread GZ
Hi All, I am looking at the following code: def fn(): def inner(x): return tbl[x] tbl={1:'A', 2:'B'} f1 = inner # I want to make a frozen copy of the values of tbl in f1 tbl={1:'C', 2:'D'} f2 = inner return (f1,f2) f1,f2 = fn() f1(1) # output C f2(1) # output