As the title says, I am interested in a list of all functions inside my python module as string. So far I have a list of function objects with their possible arguments.
For example, with NumPy
from inspect import getmembers, isfunction
import numpy
functions_list = getmembers(numpy, isfunction)
functions_list = [x[1] for x in functions_list] #functions_list = [str(x[1]).split(' ')[1] for x in functions_list]
functions_list[:4]
Output:
[<function numpy.__dir__()>,
<function numpy.__getattr__(attr)>,
<function numpy.core.function_base.add_newdoc(place, obj, doc, warn_on_python=True)>,
<function numpy.alen(a)>]
If I try list comprehension and parse the function object to a string with str(x) as follows:
functions_list = [str(x[1]) for x in functions_list]
Output:
['<function __dir__ at 0x000001C9D44AF310>',
'<function __getattr__ at 0x000001C9D40BFD30>',
'<function add_newdoc at 0x000001C9D42C0C10>',
'<function alen at 0x000001C9D42610D0>']
Same for:
str(functions_list)
repr(functions_list)
I want something like:
['numpy.__dir__()',
'numpy.__getattr__(attr)',
'numpy.core.function_base.add_newdoc(place, obj, doc, warn_on_python=True)',
'numpy.alen(a)']
How can I archive this? I know there are a lot of similar questions here, and I look up a few of them, but I couldn't find something that helps me out.