Re: Lambda forms and scoping

2009-03-23 Thread R. David Murray
Gabriel Genellina gagsl-...@yahoo.com.ar wrote: However, I think that a Python closure is not quite the same thing as a 'computer science' closure, for the same reason that people coming from a language with variables-and-values as opposed to namespaces get confused when dealing with

Re: Lambda forms and scoping

2009-03-22 Thread Gabriel Genellina
En Fri, 20 Mar 2009 23:16:00 -0300, alex goretoy aleksandr.gore...@gmail.com escribió: i looks at lambdas as unbound functions(or super function), in the case above we create the functions in a list places it in memory unboud, once binding a call to the memory address space it returns the value

Re: Lambda forms and scoping

2009-03-22 Thread R. David Murray
Gabriel Genellina gagsl-...@yahoo.com.ar wrote: En Fri, 20 Mar 2009 23:16:00 -0300, alex goretoy aleksandr.gore...@gmail.com escribió: i looks at lambdas as unbound functions(or super function), in the case above we create the functions in a list places it in memory unboud, once binding

Re: Lambda forms and scoping

2009-03-22 Thread alex goretoy
Sorry to have confused yall. What I meant was that you can do something like this, where the fucntion isn't called until it is bount to () with the right params def a(): ... print inside a ... def b(): ... print inside b ... def c(a,b): ... a() ... b() ... d={c:(a,b)}

Re: Lambda forms and scoping

2009-03-22 Thread andrew cooke
alex goretoy wrote: Sorry to have confused yall. What I meant was that you can do something like this, where the fucntion isn't called until it is bount to () with the right params def a(): ... print inside a ... def b(): ... print inside b ... def c(a,b): ... a() ...

Re: Lambda forms and scoping

2009-03-22 Thread alex goretoy
I'm talking about in function c, where we bind the function call, kinda same thing with lambdas too, exactly same def func1(a): return a def func2(a=,b=0): return %s has %d apples%(a,b) def c(f1,f2,**kwargs): print f2(kwargs['name'], f1(kwargs['apple'])) #bind call to function 1 and

Re: Lambda forms and scoping

2009-03-22 Thread Gabriel Genellina
En Sun, 22 Mar 2009 20:43:02 -0300, alex goretoy aleksandr.gore...@gmail.com escribió: Sorry to have confused yall. What I meant was that you can do something like this, where the fucntion isn't called until it is bount to () with the right params def a(): ... print inside a ...

Re: Lambda forms and scoping

2009-03-22 Thread alex goretoy
Ah, so this is a terminology issue. I'd say that a and b are *called* in function c, not *bound*. I've never seen bind used in this sense before, but as Humpty Dumpty said to Alice: i use the word expressively -Alex Goretoy http://www.goretoy.com --

Re: Lambda forms and scoping

2009-03-22 Thread Gabriel Genellina
En Sun, 22 Mar 2009 16:42:21 -0300, R. David Murray rdmur...@bitdance.com escribió: Gabriel Genellina gagsl-...@yahoo.com.ar wrote: And if you imply that *where* you call a function does matter, it does not. A function carries its own local namespace, its own closure, and its global

Re: Lambda forms and scoping

2009-03-21 Thread Márcio Faustino
On Mar 20, 12:28 pm, R. David Murray rdmur...@bitdance.com wrote: Hope this helps.  I find that thinking in terms of namespaces helps me understand how Python works better than any other mental model I've come across. It does, thanks. On Mar 20, 12:41 pm, Michele Simionato

Re: Lambda forms and scoping

2009-03-20 Thread R. David Murray
Benjamin Peterson benja...@python.org wrote: Márcio Faustino m.faustino at gmail.com writes: Executing the example below doesn't produce the expected behavior, but using the commented code does. Is this normal, or is it a problem with Python? I've tested it with version 2.6.1 on Windows

Re: Lambda forms and scoping

2009-03-20 Thread Michele Simionato
On Mar 19, 10:52 pm, Márcio Faustino m.faust...@gmail.com wrote: Hi, Executing the example below doesn't produce the expected behavior, but using the commented code does. Is this normal, or is it a problem with Python? It is a common gotcha. Notice that it has nothing to do with lambda

Re: Lambda forms and scoping

2009-03-20 Thread Márcio Faustino
So simple :) thanks! -- http://mail.python.org/mailman/listinfo/python-list

Re: Lambda forms and scoping

2009-03-20 Thread Gabriel Genellina
En Fri, 20 Mar 2009 09:28:08 -0300, R. David Murray rdmur...@bitdance.com escribió: Benjamin Peterson benja...@python.org wrote: Márcio Faustino m.faustino at gmail.com writes: Executing the example below doesn't produce the expected behavior, but using the commented code does. Is this

Re: Lambda forms and scoping

2009-03-20 Thread alex goretoy
i looks at lambdas as unbound functions(or super function), in the case above we create the functions in a list places it in memory unboud, once binding a call to the memory address space it returns the value it is basically same as doing this: def f(): print f a=f #unbound function, same as

Lambda forms and scoping

2009-03-19 Thread Márcio Faustino
Hi, Executing the example below doesn't produce the expected behavior, but using the commented code does. Is this normal, or is it a problem with Python? I've tested it with version 2.6.1 on Windows XP. Thanks, -- from abc import * from types import * import re class Base (ObjectType):

Re: Lambda forms and scoping

2009-03-19 Thread Benjamin Peterson
Márcio Faustino m.faustino at gmail.com writes: Hi, Executing the example below doesn't produce the expected behavior, but using the commented code does. Is this normal, or is it a problem with Python? I've tested it with version 2.6.1 on Windows XP. Thanks, -- from abc import *