Re: [Tutor] How to put my functions in an array

2005-01-01 Thread Danny Yoo
On Sat, 1 Jan 2005, Jacob S. wrote: > funct = {'Add Virt':addvirt,'Remove Virt':remvirt,'More > Stuff':more,"Extras":extra} > def addvirt(): > pass > def remvirt(): > pass > def more(): > pass Hi Jacob, Quick gotcha note: the definition of the 'funct' dictionary has to g

Re: [Tutor] How to put my functions in an array

2005-01-01 Thread Jacob S.
Hello. I believe it was Danny Yoo who told me about mapping functions a while back on the list... It goes along these lines... funct = {'Add Virt':addvirt,'Remove Virt':remvirt,'More Stuff':more,"Extras":extra} def addvirt(): pass def remvirt(): pass def more(): pass def extra():

Re: [Tutor] How to put my functions in an array

2004-12-30 Thread Mohamed Lrhazi
On Thu, 2004-12-30 at 03:08, Alan Gauld wrote: > > I'm slightly confused about why you need to do this? > You create a list of names (PROVISION_ACTIONS), then > you add the corresponding functions to a dictionary > by looking the names up in the globals dictionary. > But since uyou know the na

Re: [Tutor] How to put my functions in an array

2004-12-30 Thread Alan Gauld
> Thanks alot Jeff. This worked for me: > > formhandlers={} > for verb,verb_desc in PROVISION_ACTIONS: > try: > formhandlers[verb]=globals()[verb] > except KeyError: > pass I'm slightly confused about why you need to do this? You create a list of names (PROVISION_ACTIONS), then you add the cor

Re: [Tutor] How to put my functions in an array

2004-12-30 Thread Alan Gauld
I'm not sure what exa ctly you are trying to do here, but I'll take a guess. > def addvirt(): pass > def remvirt(): pass > PROVISION_ACTIONS=[('addvirt','Add Virt'),('remvirt','Remove Virt'),] Not sure why you have the list of tuples of strings, but it shouldn't be a problem. > formhandlers={} >

Re: [Tutor] How to put my functions in an array

2004-12-29 Thread 沈洁元
Hello, Mohamed Lrhazi wrote: >def addvirt(): > pass >def remvirt(): > pass > >PROVISION_ACTIONS=[('addvirt','Add Virt'),('remvirt','Remove Virt'),] >formhandlers={} > ># this works >formhandlers["addvirt"]=addvirt >formhandlers["remvirt"]=remvirt > ># this does not work: >for verb,ver

Re: [Tutor] How to put my functions in an array

2004-12-29 Thread Mohamed Lrhazi
Thanks alot Jeff. This worked for me: formhandlers={} for verb,verb_desc in PROVISION_ACTIONS: try: formhandlers[verb]=globals()[verb] except KeyError: pass On Wed, 2004-12-29 at 14:37, Jeff Shannon wrote: > If you can't make that change to PROVIS

Re: [Tutor] How to put my functions in an array

2004-12-29 Thread Jeff Shannon
Mohamed Lrhazi wrote: def addvirt(): pass def remvirt(): pass PROVISION_ACTIONS=[('addvirt','Add Virt'),('remvirt','Remove Virt'),] formhandlers={} # this works formhandlers["addvirt"]=addvirt formhandlers["remvirt"]=remvirt # this does not work: for verb,verb_desc in PROVISION_ACTI

[Tutor] How to put my functions in an array

2004-12-29 Thread Mohamed Lrhazi
def addvirt(): pass def remvirt(): pass PROVISION_ACTIONS=[('addvirt','Add Virt'),('remvirt','Remove Virt'),] formhandlers={} # this works formhandlers["addvirt"]=addvirt formhandlers["remvirt"]=remvirt # this does not work: for verb,verb_desc in PROVISION_ACTIONS: if cal