In this chapter, we will cover:
Python provides the useful ability to embed comments inside functions that are accessible from a Python shell. These are known as docstrings.
A docstring provides the ability to embed not only information, but also code samples that are runnable.
There is an old adage that comments aren't code. Comments don't undergo syntax checks and are often not maintained, thus the information they carry can lose its value over time. doctest
counters this by turning comments into code which can serve many useful purposes.
In this chapter, we will explore different ways to use doctest
to develop testing, documentation, and project support. No special setup is required, as doctest
is part of Python's standard libraries.