0
> file_name = python.py

> python.py
> def abc(x):
     """
     Hello World
     """
     pass

As you can see, inside the python.py file contains the function abc. How do I extract the docstring Hello World from it without hardcoding the function name into help() or .__doc__?

1 Answer 1

3

You can leverage pydoc for docstrings documentation.

pydoc -w python.py

There are many more options available, choose the one meeting your needs.

Source - https://www.python.org/dev/peps/pep-0256/

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.