Re: lambda (and reduce) are valuable

2005-12-16 Thread Cameron Laird
In article [EMAIL PROTECTED], Fredrik Lundh [EMAIL PROTECTED] wrote: . . . # create numeric pad digit(7, 1, 1); digit(8, 2, 1); digit(9, 3, 1) digit(4, 1, 2); digit(5, 2, 2); digit(6, 3, 2) digit(1, 1, 3);

Re: lambda (and reduce) are valuable

2005-12-14 Thread Marc 'BlackJack' Rintsch
In [EMAIL PROTECTED], Christopher Subich wrote: Chris Mellon wrote: functions with real names is crucial to maintainable code. The only reason to ever use a lamdba in Python is because you don't want to give a function a name, and that is just not a compelling use case for GUI events. Ah,

Re: lambda (and reduce) are valuable

2005-12-14 Thread bonono
Marc 'BlackJack' Rintsch wrote: In [EMAIL PROTECTED], Christopher Subich wrote: Chris Mellon wrote: functions with real names is crucial to maintainable code. The only reason to ever use a lamdba in Python is because you don't want to give a function a name, and that is just not a

Re: lambda (and reduce) are valuable

2005-12-13 Thread Christopher Subich
Chris Mellon wrote: functions with real names is crucial to maintainable code. The only reason to ever use a lamdba in Python is because you don't want to give a function a name, and that is just not a compelling use case for GUI events. Ah, but that neglects the sheer utility of

Re: lambda (and reduce) are valuable

2005-12-12 Thread Fredrik Lundh
Steven Bethard wrote: I thought stuff like the following was idiomatic in GUI programming. Do you really want separate names for all those callbacks? # generate calculator keypad buttons Button(label='7', command=lambda: user_pressed(7)).grid(column=1, row=1) Button(label='8',

Re: lambda (and reduce) are valuable

2005-12-12 Thread bonono
Steven Bethard wrote: Paul Rubin wrote: Chris Mellon [EMAIL PROTECTED] writes: As someone who does a tremendous amount of event-driven GUI programming, I'd like to take a moment to speak out against people using us as a testament to the virtues of lamda. Event handlers are the most

Re: lambda (and reduce) are valuable

2005-12-12 Thread Paul Rubin
Fredrik Lundh [EMAIL PROTECTED] writes: a temporary factory function should be sufficient: def digit(label, x, y): def callback(): # print BUTTON PRESS, label # debug! user_pressed(int(label)) Button(label=label, command=callback).grid(column=x,

Re: lambda (and reduce) are valuable

2005-12-12 Thread Paul Rubin
Paul Rubin http://[EMAIL PROTECTED] writes: binops = {'+': (lambda x,y: x+y), '-': (lambda x,y: x-y), '*': (lambda x,y: x*y), '/': (lambda x,y: x/y), '**': (lambda x,y: x**y) } How would you refactor that, with no

Re: lambda (and reduce) are valuable

2005-12-12 Thread bonono
Paul Rubin wrote: Fredrik Lundh [EMAIL PROTECTED] writes: a temporary factory function should be sufficient: def digit(label, x, y): def callback(): # print BUTTON PRESS, label # debug! user_pressed(int(label)) Button(label=label,

Re: lambda (and reduce) are valuable

2005-12-12 Thread Paul Rubin
[EMAIL PROTECTED] writes: How would you refactor that, with no lambda? Or, why would you want to refactor that ? I like it the way it was written. I'm not the one saying lambda is bogus. -- http://mail.python.org/mailman/listinfo/python-list

Re: lambda (and reduce) are valuable

2005-12-12 Thread Bengt Richter
On Mon, 12 Dec 2005 09:15:38 +0100, Fredrik Lundh [EMAIL PROTECTED] wrote: Steven Bethard wrote: I thought stuff like the following was idiomatic in GUI programming. Do you really want separate names for all those callbacks? # generate calculator keypad buttons Button(label='7',

Re: lambda (and reduce) are valuable

2005-12-12 Thread Paul Rubin
[EMAIL PROTECTED] (Bengt Richter) writes: for tup in ((str(d+1), d%3+1,3-d//3) for d in xrange(9)): digit(*tup) tweak 'til correct ;-) GMTA. See: http://www.nightsong.com/phr/python/calc.py written a couple years ago. It uses: for i in xrange(1,10):

Re: lambda (and reduce) are valuable

2005-12-11 Thread David Isaac
Alan Isaac wrote: #evaluate polynomial (coefs) at x using Horner's rule def horner(coefs,x): return reduce(lambda a1,a2: a1*x+a2,coefs) It just cannot get simpler or more expressive. Peter Otten [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] But is it correct? Yes. Are we

Re: lambda (and reduce) are valuable

2005-12-11 Thread David Isaac
Chris Mellon [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] As someone who does a tremendous amount of event-driven GUI programming, I'd like to take a moment to speak out against people using us as a testament to the virtues of lamda. Event handlers are the most important part of

Re: lambda (and reduce) are valuable

2005-12-11 Thread Paul Rubin
Chris Mellon [EMAIL PROTECTED] writes: As someone who does a tremendous amount of event-driven GUI programming, I'd like to take a moment to speak out against people using us as a testament to the virtues of lamda. Event handlers are the most important part of event-driven code, and making

Re: lambda (and reduce) are valuable

2005-12-11 Thread Steven Bethard
Paul Rubin wrote: Chris Mellon [EMAIL PROTECTED] writes: As someone who does a tremendous amount of event-driven GUI programming, I'd like to take a moment to speak out against people using us as a testament to the virtues of lamda. Event handlers are the most important part of event-driven

Re: lambda (and reduce) are valuable

2005-12-10 Thread Peter Otten
Alan aka David Isaac wrote: #evaluate polynomial (coefs) at x using Horner's rule def horner(coefs,x): return reduce(lambda a1,a2: a1*x+a2,coefs) It just cannot get simpler or more expressive. But is it correct? a0, a1, a2 = 1, 2, 3 x = 2 a0 + x*(a1 + x*(a2)) 17 def horner(coefs, x):

Re: lambda (and reduce) are valuable

2005-12-10 Thread bonono
Peter Otten wrote: Alan aka David Isaac wrote: #evaluate polynomial (coefs) at x using Horner's rule def horner(coefs,x): return reduce(lambda a1,a2: a1*x+a2,coefs) It just cannot get simpler or more expressive. But is it correct? a0, a1, a2 = 1, 2, 3 x = 2 a0 + x*(a1 + x*(a2))

Re: lambda (and reduce) are valuable

2005-12-10 Thread Chris Mellon
On 12/9/05, David Isaac [EMAIL PROTECTED] wrote: Jibes against the lambda-clingers lead eventually to serious questions of style in regard to variable namespacing, lifespan, cleanup, and so on:

Re: lambda (and reduce) are valuable

2005-12-09 Thread David Isaac
Jibes against the lambda-clingers lead eventually to serious questions of style in regard to variable namespacing, lifespan, cleanup, and so on: http://groups.google.com/group/comp.lang.python/browse_thread/thread/ad0e15cb6b8f2c32/ Alan Isaac [EMAIL PROTECTED] wrote: #evaluate