ignored return codes
Alex Martelli
aleax at aleax.it
Sun Apr 7 11:55:15 EDT 2002
Bengt Richter wrote:
...
>>Button(buttonsFrame, text='Squirk', command=lambda: self.squirkIt(23, 45))
>>
>>you can code:
>>
>>def specificSquirker(): self.squirkIt(23, 45)
> ^-- return
> if you really want equivalent code, though maybe only side effects matter
> in the the example context?
Yes, the return code of command= callables is ignored (thus I never
code a return in those cases) -- sorry, I had dropped into Tkinter
mindset here.
>>Button(buttonsFrame, text='Squirk', command=specificSquirker)
Another nice alternative, btw, is
Button(buttonsFrame, text='Squirk', command=curry(self.squickIt, 23, 45))
Look up curry in the Python Cookbook if it only suggests Indian food to
you...:-).
Alex
More information about the Python-list
mailing list