B
bruno at modulix
egbert said:What does a gui_event_loop know ?
My gui is based on pygtk,
but i suppose the mechanism is the same everywhere.
The gui is created within a class-instance within a function.
Normally, ie without a gui, everything that happens within
a function is forgotten as soon the function ends.
But in a gui_event_loop the callback-method within the function
can be called, and this callbacks calls another function
also within the same first function.
And that function already stopped.
s/stopped/returned/
I guess that what bother you has to do with closures.
def foo(bar):
buu = "buu"
def baaz(baak):
print bar, buu, baak
print "foo(%s") return..." % bar
return baaz
dodo = Foo('parrot')
dudu = Foo('dead')
dodo(42)
dudu("ni")
As you can see, after foo() has returned, dodo() and dudu() 'remember'
the environment in which they where created. A closure is a function
that carries it's environment with it.
http://en.wikipedia.org/wiki/Closure_(computer_science)Maybe somebody can explain what is going on, or where I can find
further explanations.
http://www.python.org/dev/peps/pep-0227/
http://docs.python.org/ref/naming.html#naming
HTH