generating method names 'dynamically'

Murali maha.murali at gmail.com
Thu Jan 26 19:06:19 EST 2006


x.__class__.__dict__[mname](x,*args,**kwargs)

here
x is an instance of a class FOO
FOO has a method "bar" (if the value of mname is "bar")
args is a tuple whose length is the number of positional arguments
accepted by bar
kwargs is a dictionary corresponding to the keyword arguments accepted
by bar.

Hope this answers your questions. 

- Murali




More information about the Python-list mailing list