Block 154: Code Documentation & Docstrings
Add comprehensive docstrings and inline comments.
Concepts
- Google-style and NumPy-style docstrings
- sphinx autodoc concept
- Inline comments: when they help vs when they clutter
- Type hints: def func(x: float) -> str:
Code Examples
See exercise below.
Exercise
Add complete docstrings to every function in your project (what it does, parameters, returns, raises). Add type hints to at least 5 functions.
Homework
What is the difference between a docstring and an inline comment? Give an example of each used correctly. Wednesday