More Tkinter menu problems
kiki
kiki at pixar.com
Fri Jun 4 02:06:26 EDT 1999
> Another possible way of implemented getting the same result, without
> resorting to unreadable lambda expressions is to create a class
> something like...
>
> class Command:
> def __init__(self, func, *args, **kw):
> self.func = func
> self.args = args
> self.kw = kw
>
> def __call__(self, *args, **kw):
> args = self.args + args
> kw.update(self.kw)
> apply(self.func, args, kw)
>
> then...
>
> command = Command(self.select_color, new_color)
>
> This costs one extra function call when it is used, but I think the
> decrease in complexity of the expression make it worth it.
>
> --
> Tim Evans
Great! Thanx. That worked well.
Kiki
More information about the Python-list
mailing list