Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > calling obect method

Reply
Thread Tools

calling obect method

 
 
srinivasan srinivas
Guest
Posts: n/a
 
      07-30-2009
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


See the Web's breaking stories, chosen by people like you. Check out Yahoo! Buzz. http://in.buzz.yahoo.com/
 
Reply With Quote
 
 
 
 
r
Guest
Posts: n/a
 
      07-30-2009
>>> import math
>>> getattr(math, 'hypot')(3,4)

5.0
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Getting references to obect instances into a list parent.eric.3@gmail.com Python 9 08-27-2008 04:15 PM
dynamic obect access =?Utf-8?B?cGVsZWdrMQ==?= ASP .Net 1 07-15-2007 08:25 AM
dynamic obect access pelegk1 ASP .Net 0 07-14-2007 11:40 PM
Why does this cause an Obect required message? It seems to work... Iver Erling Årva Javascript 2 08-19-2004 10:17 AM
Switching obect's type--sort of. Joseph Cook C++ 7 11-21-2003 07:44 PM



Advertisments