Re: Understanding closures

2007-08-19 Thread James Stroud
Ramashish Baranwal wrote: > Hi, > > I want to use variables passed to a function in an inner defined > function. Something like- > > def fun1(method=None): > def fun2(): > if not method: method = 'GET' > print '%s: this is fun2' % method > return > fun2() > > fun1

Re: Understanding closures

2007-08-18 Thread happyriding
On Aug 18, 11:03 pm, Ramashish Baranwal <[EMAIL PROTECTED]> wrote: > Hi, > > I want to use variables passed to a function in an inner defined > function. Something like- > > def fun1(method=None): > def fun2(): > if not method: method = 'GET' > print '%s: this is fun2' % method

Re: Understanding closures

2007-08-18 Thread Alex Martelli
Ramashish Baranwal <[EMAIL PROTECTED]> wrote: > Hi, > > I want to use variables passed to a function in an inner defined > function. Something like- > > def fun1(method=None): > def fun2(): > if not method: method = 'GET' > print '%s: this is fun2' % method > return >

Understanding closures

2007-08-18 Thread Ramashish Baranwal
Hi, I want to use variables passed to a function in an inner defined function. Something like- def fun1(method=None): def fun2(): if not method: method = 'GET' print '%s: this is fun2' % method return fun2() fun1() However I get this error- UnboundLocalError: loc