Lambda forms and scoping

Gabriel Genellina gagsl-py2 at yahoo.com.ar
Mon Mar 23 02:53:17 CET 2009


En Sun, 22 Mar 2009 20:43:02 -0300, alex goretoy  
<aleksandr.goretoy at 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"
> ...
>>>> def b():
> ...     print "inside b"
> ...
>>>> def c(a,b):
> ...     a()
> ...     b()
> ...
>>>> d={c:(a,b)}
>>>> d[c][0]()
> inside a
>>>> d[c][1]()
> inside b
>>>> d[c(d[c][0],d[c][1])]
> inside a
> inside b
> Traceback (most recent call last):
>   File "<stdin>", line 1, in <module>
> KeyError: None
>
> where function a and b are bound in function c

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:

- When I use a word, it means just what I choose it to mean -- neither  
more nor less.
- The question is, whether you can make words mean so many different  
things.
- The question is, which is to be master -- that's all.

(Lewis Carroll, Through the Looking Glass, ch. VI)

-- 
Gabriel Genellina




More information about the Python-list mailing list