On Wed, 07 Nov 2007 01:37:00 +0100, Chris Mellon <[EMAIL PROTECTED]> wrote:
> Are there languages where closures *don't* behave like this? A closure
> that used a copy of the state rather than the actual state itself
> doesn't seem as useful. For references sake, JavaScript (the only
> language th
On Nov 6, 5:37 pm, "Chris Mellon" <[EMAIL PROTECTED]> wrote:
> On Nov 6, 2007 6:23 PM, Jean-Paul Calderone <[EMAIL PROTECTED]> wrote:
>
> > On Tue, 06 Nov 2007 17:07:47 -0700, Fernando Perez <[EMAIL PROTECTED]>
> > wrote:
> > > [snip]
>
> > >This struck me as counterintuitive, but I couldn't find
Michele Simionato a écrit :
> On Nov 6, 7:37 pm, "Chris Mellon" <[EMAIL PROTECTED]> wrote:
>> On Nov 6, 2007 6:23 PM, Jean-Paul Calderone <[EMAIL PROTECTED]> wrote:
>>> Lots of people ask about this. The behavior you observed is the expected
>>> (by the implementors, anyway) behavior.
>> Are there
On Nov 6, 7:37 pm, "Chris Mellon" <[EMAIL PROTECTED]> wrote:
> On Nov 6, 2007 6:23 PM, Jean-Paul Calderone <[EMAIL PROTECTED]> wrote:
> > Lots of people ask about this. The behavior you observed is the expected
> > (by the implementors, anyway) behavior.
>
> Are there languages where closures *don
Diez B. Roggisch wrote:
> It's a FAQ. The reason is that the created closures don't capture the
> _value_, but the _name_. Plus of course the locals()-dictionary outside
> the function a to perform the lookup of that name. Which has the value
> bound to it in the last iteration.
>
> Common cure
On Nov 6, 2007 6:23 PM, Jean-Paul Calderone <[EMAIL PROTECTED]> wrote:
> On Tue, 06 Nov 2007 17:07:47 -0700, Fernando Perez <[EMAIL PROTECTED]> wrote:
> > [snip]
> >
> >This struck me as counterintuitive, but I couldn't find anything in the
> >official docs indicating what the expected behavior sho
Fernando Perez schrieb:
> Hi all,
>
> consider the following small example:
>
> """
> Small test to try to understand a strange subtlety with closures
> """
>
> def outer(nmax):
>
> aa = []
> for n in range(nmax):
>
> def a(y):
> return (y,n)
> print 'Closur
On Tue, 06 Nov 2007 17:07:47 -0700, Fernando Perez <[EMAIL PROTECTED]> wrote:
> [snip]
>
>This struck me as counterintuitive, but I couldn't find anything in the
>official docs indicating what the expected behavior should be. Any
>feedback/enlightenment would be welcome. This problem appeared deep
Hi all,
consider the following small example:
"""
Small test to try to understand a strange subtlety with closures
"""
def outer(nmax):
aa = []
for n in range(nmax):
def a(y):
return (y,n)
print 'Closure and cell id:',id(a.func_closure),\
id(a.