Terry Reedy 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!"
--
http://mail.
John Posner 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,
Scott David Daniels writes:
> Giacomo Boffi wrote:
>> Giacomo Boffi 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+' <->
>> '+c2).p
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:
#---
Giacomo Boffi wrote:
"Diez B. Roggisch" 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: output(c1+'->'
Giacomo Boffi wrote:
Giacomo Boffi 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+' <-> '+c2).pack(side='left',expand=1,fill='both')
| Button(su
Giacomo Boffi 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]):
| subframe=Frame(fr)
|
"Diez B. Roggisch" 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: output(c1+'->'+c2)
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+' <->
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')
10 matches
Mail list logo