0

I am wondering if there is already something to get a list of function's names inside a script.py file.

Example:

I have a script.py that has the following inside:

def func_1():
    message = 'Function 1'
    return message

def func_2():
    message = 'Function 2'
    return message

def func_3():
    message = 'Function 3'
    return message

And I want to write a function to get something like this:

functions = getAllFunctions('script.py')
functions = ['func_1', 'func_2', 'func_3'] # expected return value

I want to write that getAllfunctions() function.

martineau
  • 112,593
  • 23
  • 157
  • 280

0 Answers0