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,verb_desc in PROVISION_ACTIONS:
>       if callable(verb):
>  
>
#### Here is the bug, verb here is a string, not a function entry.
callable(Function) will return True. callable(String) always returns False.

>               formhandlers[verb]=verb
>
>I tried a few different syntaxes but to no avail... do I need things
>like: getattr()? 
>
>Thanks alot
>Mohamed~
>
I hope this will meet your needs in a clear way:

def addvirt():
pass

def remvirt():
pass

PROVISION_ACTIONS=[(addvirt,'Add Virt'),(remvirt,'Remove Virt')]
formhandlers={}

for (verb,verb_descr) in PROVISION_ACTIONS:
if callable(verb):
formhandlers[verb.__name__]=verb


_______________________________________________
Tutor maillist  -  [email protected]
http://mail.python.org/mailman/listinfo/tutor

Reply via email to