Calling a function or method by name

Gustavo Córdova Avila gcordova at sismex.com
Wed Jan 23 13:41:02 EST 2002


Maybe with something like:

def call_method(obj,name,*args,**kwargs):
	try:
		f = getattr(obj,name)
	except:
		f = None
	if callable(f): apply(f, args, kwargs)

??

-gus




More information about the Python-list mailing list