(resending to include Tutor -- sorry for the dupe, Christopher)

On 16/06/06, Christopher Spears <[EMAIL PROTECTED]> wrote:
> I have been reading though the PyGTK tutorial.
> Can anyone explain how lambda is being used in this
> statement:
>
> button.connect("clicked", lambda w: gtk.main_quit())


Do you understand what lambda does in general?

Does it help if I rewrite the code like this:

def onQuit(w):
   gtk.main_quit()
button.connect("clicked", onQuit)

?

Provided you get your indentation correct ("def onQuit" and
"button.connect" should be at the same level), and provided you aren't
using the name "onQuit" somewhere else in that method, this code
should be a dropin replacement for the line you quote.

--

John.
_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to