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
  • 119,623
  • 25
  • 170
  • 301
  • Can you do `import script` or does it need to be from the string `'script.py'` ? – azro May 30 '22 at 17:22
  • I has to be from the string 'script.py', I will parse all files with extensions (.py) inside a folder and then list the functions inside each file. – derHund1877 May 30 '22 at 18:34
  • @derHund1877: Wasn't me who gave you link — was the three users that closed your question. – martineau May 30 '22 at 18:44

0 Answers0