Re: What are python closures realy like?

2006-12-02 Thread Karl Kofnarson
> Karl, > > Usually when using this idiom, fun_basket would return a tuple of all of the > defined functions, rather than one vs. the other. So in place of: >>if f == 1: >>return f1 >>if f == 2: >>return f2 > Just do >>return f1, f2 > (For that matter, the argument f

What are python closures realy like?

2006-12-01 Thread Karl Kofnarson
Hi, while writing my last program I came upon the problem of accessing a common local variable by a bunch of functions. I wanted to have a function which would, depending on some argument, return other functions all having access to the same variable. An OO approach would do but why not try out cl