Adding Function Docstrings
Add Function Docstrings to Your Python Project. It’s time to add Google-style docstrings to your example functions in
calculations.py. Start by writing your one-line docstring, which should concisely explain the purpose of the function.
00:24 After adding the initial description of your function, you can then expand the docstring to describe the function arguments and the function’s return value.
You can keep inspecting your functions by using
help() to peek at the automatic documentation that Python builds from the information that you add to the function docstrings.
By describing the arguments and the return value and their types, you provide helpful usage information for programmers working with your code. Go on to write docstrings for all functions in
03:52 When you’re done, you’ve successfully added the first stage of your project code documentation directly into your codebase. But Python docstrings can do more than describe and document.
04:04 You can even use them to include short test cases for your functions, which you can execute using one of Python’s built-in modules. And that’s what you’ll see in the next section of the course.
Become a Member to join the conversation.