calling obect method

Benjamin Kaplan benjamin.kaplan at case.edu
Thu Jul 30 18:08:21 EDT 2009


On Thu, Jul 30, 2009 at 3:04 PM, srinivasan srinivas <
sri_annauni at yahoo.co.in> wrote:

> Hi,
> I would like to know if i have an object and one of its methods as a
> string. How to call the method using this string?
> For ex
> If object is x and string y has one of its method names.
> x.value(y)() ---. Is there a way to do this?
>
> Thanks,
> Srini



getattr(x,y)()

>
>
>
>      See the Web's breaking stories, chosen by people like you. Check out
> Yahoo! Buzz. http://in.buzz.yahoo.com/
> --
> http://mail.python.org/mailman/listinfo/python-list
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20090730/fa5a0b18/attachment-0001.html>


More information about the Python-list mailing list