Scott David Daniels scott.dani...@acm.org writes:
Giacomo Boffi wrote:
Giacomo Boffi giacomo.bo...@polimi.it writes:
...
| def create_cb(a,b):
| return lambda: output(a+'-'+b)
| | def doit(fr,lst):
| for c1,c2 in zip(lst[::2], lst[1::2]):
| subframe=Frame(fr)
|
John Posner jjpos...@optimum.net writes:
def output(x,y,op):
if op == :
print x, ---, y
elif op == :
print x, ---, y
else:
print Operation argument error!
uh, nice!, i'll adapt this to my real problem
thank you John,
Terry Reedy tjre...@udel.edu writes:
Reedy's Lambda Rule: [detailed explanation omitted]
i'm beginning to _understand_ what's going on with my code
Terry Jan Reedy
thanks, grazie 1000 Terry,
g
--
Lord, what fools these mortals be!
--
i have this test program (that i already posted on it.comp.lang.python)
[ test.py ]
from Tkinter import *
def output(s):
print s
def doit(fr,lst):
for c1,c2 in zip(lst[::2], lst[1::2]):
subframe=Frame(fr)
Label(subframe,text=c1+' - '+c2).pack(side='left',expand=1,fill='both')
Giacomo Boffi wrote:
i have this test program (that i already posted on it.comp.lang.python)
[ test.py ]
from Tkinter import *
def output(s):
print s
def doit(fr,lst):
for c1,c2 in zip(lst[::2], lst[1::2]):
subframe=Frame(fr)
Label(subframe,text=c1+' -
Diez B. Roggisch de...@nospam.web.de writes:
Giacomo Boffi wrote:
def doit(fr,lst):
for c1,c2 in zip(lst[::2], lst[1::2]):
subframe=Frame(fr)
Label(subframe,text=c1+' -
'+c2).pack(side='left',expand=1,fill='both')
Button(subframe,text='',command=lambda:
Giacomo Boffi giacomo.bo...@polimi.it writes:
ok, i'll try again following your advice
,[ test.py ]
| from Tkinter import *
|
| def output(s):
| print s
|
| def create_cb(a,b):
| return lambda: output(a+'-'+b)
|
| def doit(fr,lst):
| for c1,c2 in zip(lst[::2], lst[1::2]):
|
Giacomo Boffi wrote:
Giacomo Boffi giacomo.bo...@polimi.it writes:
...
| def create_cb(a,b):
| return lambda: output(a+'-'+b)
|
| def doit(fr,lst):
| for c1,c2 in zip(lst[::2], lst[1::2]):
| subframe=Frame(fr)
| Label(subframe,text=c1+' -
Giacomo Boffi wrote:
Diez B. Roggisch de...@nospam.web.de writes:
Giacomo Boffi wrote:
def doit(fr,lst):
for c1,c2 in zip(lst[::2], lst[1::2]):
subframe=Frame(fr)
Label(subframe,text=c1+' -
'+c2).pack(side='left',expand=1,fill='both')
Button(subframe,text='',command=lambda:
snip
def cb12(): return output(c1+'-'+c2)
def cb21(): return output(c2+'-'+c1)
I think these can be simplified, e.g:
def cb12(): output(c1+'-'+c2)
But I'd go with the functools.partial approach. You can save some code
by making output() do more of the work:
10 matches
Mail list logo