is it possible to create an object by its name in the run time

Golawala, Moiz M (GE Infrastructure) Moiz.Golawala at ge.com
Tue Aug 17 14:43:01 EDT 2004


to find all builtins try  dir(__builtins__)

to get all functions in the modules try dir(moduleName)
to get all the modules that you imported just type dir()
to get all the methods in the class type dir(className)

hope this helps.

Moiz Golawala
GE Infrastructure, Security
Software Engineer
Enterprise Solutions

T 561 994 5972
F 561 994 6572
E moiz.golawala at ge.com 
www.gesecurity.com

791 Park of Commerce Blvd., Suite 100
Boca Raton, FL, 33487, U.S.A.
GE Security, Inc.


-----Original Message-----
From: python-list-bounces+moiz.golawala=ge.com at python.org [mailto:python-list-bounces+moiz.golawala=ge.com at python.org]On Behalf Of Yang Zhang
Sent: Tuesday, August 17, 2004 2:38 PM
To: python-list at python.org
Subject: is it possible to create an object by its name in the run time


 Hi all,
        I wonder if it is possible to create an object of func, class or
 method in the run time by it's name? To make it more clear, let me show
 you an example: I parsed the python code and found a function with name
'len'.
 I want to know if it is a build-in func(where can I look up?). If so,
ignore
 it otherwise I want to find out which module is it defined in. All I know
 is the name (which is a string), and all the modules that this program have
 imported. In the same way, I also need to process the class and methods
 call. I wonder if it is possible? I will appreciate your help very much!!

-Ryan
-- 
http://mail.python.org/mailman/listinfo/python-list



More information about the Python-list mailing list