Need to call functions/class_methods etc using string ref :How

Ravi Kumar ra21vi at gmail.com
Mon Nov 26 05:37:03 EST 2007


Hi,
First of all, since this is my first mail to Python-List, I want to say
"Hello world!"
After that;
I am stuck in a project. Actually I am writing a module (for testing now),
which takes URL, parses it, finds which modules and then which method to
call or which class to initiate and which string to load.
So far, I have done some basic URL manipulation and validation and extracted
the name of modules in  a dict
{
  'ModuleName-1': None,
  'ModuleName-2': None
  --ETC--
}

Now I want your help about how to call the  function i.e _render() in the
module. I have to iterate it calling all modules/also Class.methods and
assinging the values in dict for each key as modulename.
Means,
just take that moduleName is a string which contains the name of module to
load.
FuncName is the string which contains the name of def <function> to call
clName is the string which contains the name of the Class, which is to init
and get returned object.

means everything in string.
ALso, if there are multiple methods to do it, if you provide a little
pros/cons and comments, it would really be very nice of you.


Before I came here, I have searched Google, and found a way
hasattr()/getattr(), but that confused me a little and didnt worked for me.
I am missing something I know, so please ENLIGHTEN Me :)


Thanks in advance EVen you read this mail :P

-- 
-=Ravi=-
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20071126/ee09bf48/attachment.html>


More information about the Python-list mailing list