Twisted (or for loops ?) madness

looping kadeko at gmail.com
Mon Oct 15 07:01:49 EDT 2007


On Oct 15, 12:33 pm, Michele Simionato <michele.simion... at gmail.com>
wrote:
> is a design decision, in the sense that Python always do late binding.
> If you

> you will get funclist[0]() == funclist[1]() == funclist[2]() == 3 (you
> get the latest
> binding of "i"). As you see, it has nothing to do with lambdas.
>

Thanks Diez, replacing my addCallback with d.addCallback(lambda
result, comp=c: comp.compile()) do the trick.

So if I understand what Michele wrote (thanks too), when a function is
defined (with def), no scope is saved and every variable value not
passed in parameter is lost ?  It means that variable value come from
the outer scope when the function is called ?





More information about the Python-list mailing list