Function returns a function

Gregory Bond gnb at itga.com.au
Wed Sep 7 04:29:24 CEST 2005


Paul Rubin wrote:

> 
>     def FunctionMaker(avar, func, label):
>        def callback():
>           avar.set(label)
>           func()
>        return callback

I've seen this idiom a lot and I know _what_ it does..... but I can't 
work _how_ it does it.  How does the name binding work so that "avar" in 
the returned function still references the object passed into the 
(long-distant!) FunctionMaker() call?

Web pages / turotial ptrs etc gladly accepted.



More information about the Python-list mailing list