lambda

Nick Perkins nperkins7 at home.com
Wed May 23 18:03:40 EDT 2001


"Laura Creighton" <lac at cd.chalmers.se> wrote in message
> I use lambda for things like this:
...
>     buttonList = (
>         ['show', lambda x = w: x.grid(row=0, col=0, columnspan= 5)],
>         ['pink', lambda x = w: x.configure(fg='pink')],
>         ['yellow', lambda x = w: x.configure(bg='yellow')],
>         ['Exit', root.destroy],
>         )

yep, neat.
...but how 'bout this:

     buttonList = (
         ['show', curry(w.grid, row=0, col=0, columnspan= 5)],
         ['pink', curry(w.configure, fg='pink')],
         ['yellow', curry(w.configure, bg='yellow')],
         ['Exit', root.destroy],
         )


(curry.py is in the cookbook)






More information about the Python-list mailing list