Re: Strange behavior when printing a returned closure function

2007-03-25 Thread dartsch
On Mar 25, 1:04 pm, Jean-Paul Calderone <[EMAIL PROTECTED]> wrote: > On 25 Mar 2007 03:59:52 -0700, [EMAIL PROTECTED] wrote: > > > > >Hello, > > >when I execute the following code (python 2.5) > > >def f(x): > >def g(): > >return x > >return g > > >print f(1) > >print f(2) > > >I ge

Strange behavior when printing a returned closure function

2007-03-25 Thread dartsch
Hello, when I execute the following code (python 2.5) def f(x): def g(): return x return g print f(1) print f(2) I get an output like So according to print I get the same function object returned at both calls. That's surprising, I would expect to get two distinct function o