Getting definition list

vincent wehren vincent at visualtrans.de
Sat Mar 6 14:24:13 CET 2004


"Bluexcell" <bluexcell at aol.com> schrieb im Newsbeitrag
news:20040306071202.18241.00000981 at mb-m06.aol.com...
| ok so i  use import to import a py file into my script.
|
| is there a way to list all the defined function labels that exist in the
| imported file?
|
| ie if  i import a file called test and test has defined functions  called
| myfunction1 my function2  myfunction3 etc    but i dont know  them,  is
there a
| method to list all the function labels in test and print them  as a
listing
|
| test.mfunction1
| test.myfunction2
| test.myfunction3
|
| etc.

Roughly (untested) something like the following should get you started:

import some_module
import types
d = some_module.__dict__
for k in d:
    obj = d[k]
    if type(obj) == types.FunctionType:
        print "some_module.%s" % k


HTH,

Vincent Wehren




|
|
|
|





More information about the Python-list mailing list