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);
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,
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
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
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',
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
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,
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
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,
[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
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',
[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):
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
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
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
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
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):
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))
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:
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
20 matches
Mail list logo