Calling function keywords from a dictionary

Alexander Straschil e9526547 at stud3.tuwien.ac.at
Fri Mar 26 05:45:17 EST 2004


Hello!

I'm fooling around with a class wich can map cgi-parameters to
function named parameter.

I have a dic like
 dic = {
 	'action': 'myfunc',
	'x': 1,
	'y': 2,
	'z': 3
 }
 and I have a method
 def myfunc(x, y, z, a=None, b=None)

What I want to do ist calling the method defined in 'action' with
all the named parameter, also instead of
 self.myfunct(x=1, y=2, z=3)
I want to do
 f = getattr(self, dic['action'])
 f(named parameter from the dic)
Its a little like zope does it, but i didnt find it in the Zope Sources ;-)
How can do that? 

Thanks, AXEL.



More information about the Python-list mailing list