Howto generate a metafunction? [Python 1.5.2]
Kim Petersen
kp at kyborg.dk
Tue Oct 15 12:57:48 EDT 2002
The below code should give an idea of what i want?
from Tkinter import *
class MListbox(Frame):
def __init__(self,master,count=1,cnf={},**args):
Frame.__init__(self,master,cnf)
self.listboxes=[]
for i in range(count):
self.listboxes.append(Listbox(self,command=self._docommand))
self.listboxes[-1].grid(row=0,column=i)
self.yview=self.Metafun(Listbox.yview)
self.yview_fraction=self.Metafun(Listbox.yview_fraction)
...
def Metafun(self,fun):
# How do i generate this one - to apply this function to every
# element in self.listboxes?
# - please no listcomprehensions and no def in def
# since i'm bound in this one to 1.5.2
#
# . metafun should take any amount of args (*arg)
# . metafun applies fun to every element in self.listboxes
pass
More information about the Python-list
mailing list