Edmunds Cers wrote:
> Peter Otten <__pete...@web.de> writes:
>
>> I don't know how to express it more clearly, so here's another example:
>>
> def f():
>> ... def g(): return a * a
>> ... def h(): return a + a
>> ... a = 5
>> ... return g, h
>> ...
> g, h = f()
> g(),
Peter Otten <__pete...@web.de> writes:
> I don't know how to express it more clearly, so here's another example:
>
def f():
> ... def g(): return a * a
> ... def h(): return a + a
> ... a = 5
> ... return g, h
> ...
g, h = f()
g(), h()
> (25, 10)
IMHO this whole con
iu2 wrote:
> I thought a function definition creates a closure around all used
> vars.
> As I understand now only variables that are passed as function
> arguments can participate in a closure.
No, it's just that all closures see the value of a variable at the time when
the closure is run, not w
On Jan 24, 9:51 am, Peter Otten <__pete...@web.de> wrote:
> iu2 wrote:
> > I'm trying to convert functions - pass a few functions to a converting
> > function, which change their behaviour and return the changed
> > functions:
>
> > >>> def cfuncs(*funcs):
> > n = []
> > for f in fu
iu2 wrote:
> I'm trying to convert functions - pass a few functions to a converting
> function, which change their behaviour and return the changed
> functions:
>
> >>> def cfuncs(*funcs):
> n = []
> for f in funcs:
> def ff(*args, **key):
>