tkinter question

Moshe Zadka moshez at math.huji.ac.il
Tue Jun 13 00:50:05 EDT 2000


On Mon, 12 Jun 2000, Rainer Deyke wrote:

> Bob van der Poel <bvdpoel at uniserve.com> wrote in message
> news:39454A0E.1A630514 at uniserve.com...
> 
> > Third, how can I define a widget command with an arg. For example:
> >
> > q = Button( text="Quit", command = quitit("sure?") )
> 
> One word: lambda.

There's this joke, about a person who's asked "In one word, how's it
going?" "Good" "And in two words?" "Not good"

In three words: don't use lambda <wink>

There are lots of ways to write classes to help this work smoothly:

class Curry:

	def __init__(self, func, *args):
		self.args = args
		self.func = func

	def __call__(self, *args):
		return apply(self.func, self.args+args)

Use like

f = Curry(operation.add, 1)
f(2) ==> 3

Much stabler them lambdas, because it doesn't depend on scoping
--
Moshe Zadka <moshez at math.huji.ac.il>
http://www.oreilly.com/news/prescod_0300.html
http://www.linux.org.il -- we put the penguin in .com





More information about the Python-list mailing list