[Tkinter-discuss] [Fwd: Re: lambda function to simplify]
michael.odonnell at uam.es
Sat Dec 18 18:53:01 CET 2010
> self.root.protocol('WM_DELETE_WINDOW', lambda : greeting(self))
I've had trouble with lambdas, because variables are not resolved
at declaration time, but at execution time. WOuld not the following be better:
self.root.protocol('WM_DELETE_WINDOW', lambda w=self : greeting(w))
....too tired to actually test your code.
On Sat, Dec 18, 2010 at 2:53 AM, Michael Lange <klappnase at web.de> wrote:
> Thus spoketh craf <prog at vtr.net>
> unto us on Fri, 17 Dec 2010 19:15:39 -0300:
>> My guess is that if the instruction...
>> self.root.protocol('WM_DELETE_WINDOW', lambda:((lambda
>> can be shortened to occupy the same line?
>> It's for a better understanding of the code.
> Oh yes, I misunderstood you.
> And yes, this line looks a little like a candidate for one of those
> obfuscated python contests ;) In fact right now I stare at it and I'm
> quite amazed that it works at all :) (maybe I should mention that it's 3
> a.m. here).
> I think
> should do the trick, too.
> .-.. .. ...- . .-.. --- -. --. .- -. -.. .--. .-. --- ... .--. . .-.
> Captain's Log, star date 21:34.5...
> Tkinter-discuss mailing list
> Tkinter-discuss at python.org
More information about the Tkinter-discuss