Getting definition list

B

Bluexcell

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.
 
V

vincent wehren

| 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




|
|
|
|
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,184
Messages
2,570,973
Members
47,530
Latest member
jameswilliam1

Latest Threads

Top