Ron Griswold wrote:
I'm almost positive I've seen a function somewhere that will call a
method of an object given the method's name. Something like:
apply(obj, func_name, args)
is equivalent to:
obj.func_name(args)
For some reason I thought this was the apply function, but that doesn't
First, get the method with getattr() and then use the *-notation or
apply to call it with args.
getattr(obj, func_name)(*args)
or
apply(getattr(obj, func_name), args)
Jeff
pgpm38MC4TzIU.pgp
Description: PGP signature
--
http://mail.python.org/mailman/listinfo/python-list
Just the ticket. Thank you!
Ron Griswold
Character TD
R!OT Pictures
[EMAIL PROTECTED]
-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf
Of Fredrik Lundh
Sent: Monday, December 05, 2005 3:58 PM
To: python-list@python.org
Subject: Re: apply()?
Ron Griswold