Re: Lambda forms and scoping

2009-03-23 Thread R. David Murray
"Gabriel Genellina" 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 Python function ca

Re: Lambda forms and scoping

2009-03-22 Thread Gabriel Genellina
En Sun, 22 Mar 2009 16:42:21 -0300, R. David Murray escribió: "Gabriel Genellina" 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 namespace. At call time, no additional "binding

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 -- http://mail.python.org/mailman/listi

Re: Lambda forms and scoping

2009-03-22 Thread Gabriel Genellina
En Sun, 22 Mar 2009 20:43:02 -0300, alex goretoy 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" ... def b(): ... print "in

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 an

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

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:

Re: Lambda forms and scoping

2009-03-22 Thread R. David Murray
"Gabriel Genellina" wrote: > En Fri, 20 Mar 2009 23:16:00 -0300, alex goretoy > 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 r

Re: Lambda forms and scoping

2009-03-22 Thread Gabriel Genellina
En Fri, 20 Mar 2009 23:16:00 -0300, alex goretoy 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 it is basically same as do

Re: Lambda forms and scoping

2009-03-21 Thread Márcio Faustino
On Mar 20, 12:28 pm, "R. David Murray" 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 wrote: > This post http://www.artim

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 a

Re: Lambda forms and scoping

2009-03-20 Thread Gabriel Genellina
En Fri, 20 Mar 2009 09:28:08 -0300, R. David Murray escribió: Benjamin Peterson wrote: Márcio Faustino 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

Re: Lambda forms and scoping

2009-03-20 Thread Michele Simionato
On Mar 19, 10:52 pm, Márcio Faustino 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 functions, you would

Re: Lambda forms and scoping

2009-03-20 Thread R. David Murray
Benjamin Peterson wrote: > Márcio Faustino 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 XP. > > > > Thanks, >

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-19 Thread Benjamin Peterson
Márcio Faustino 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 * >

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): __m