0

Im trying to get all the function names, with their arguments, and return's of a python file, using python script.

Tried to use AST library with FunctionDef class but couldn't able to extract the information I'm looking for.

Thanks.

1
  • 2
    have you checked module inspect which is there is python stdlib? Commented May 31, 2021 at 5:46

1 Answer 1

1

This answer recommends the inspect module for getting a list of functions; it can be used (but isn't required) for accessing function parameter names. To the best of my knowledge, Python's design doesn't really allow getting this information about a function's return values; so you might have to annotate those yourself, be it with a docstring, custom attribute, type hint, etc.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.