Search code examples
functionpython-2.7user-defined-functionsbuilt-in

how to find user defined functions in python script


A python program has builtin functions and user defined functions in it. I wish to list out all the user defined functions in that program. Could any one suggest me the way to how to do it?

example:

class sample():

     def __init__(self):
         .....some code....
     def func1():
         ....some operation...
     def func2():
         ...some operation..

I need output like this:

func1

func2

Solution

  • This isn’t strictly true. The dir() function “attempts to produce the most relevant, rather than complete, information”. Source:

    How do I get list of methods in a Python class?

    Is it possible to list all functions in a module?