Commenting Python Code
Programming reflects your way of thinking in order to describe the single steps that you took to solve a problem using a computer. Commenting your code helps explain your thought process, and helps you and others to understand later on the intention of your code. This allows you to more easily find errors, to fix them, to improve the code later on, and to reuse it in other applications as well.
Commenting is important to all kinds of projects, no matter whether they are – small, medium, or rather large. It is an essential part of your workflow, and is seen as good practice for developers. Without comments, things can get confusing, real fast. In this article we will explain the various methods of commenting Python supports, and how it can be used to automatically create documentation for your code using the so-called module-level docstrings.
As important as comments are, it’s still possible to write bad comments. They should always be short, straight to the point, and add informative value.
For example, this is a rather useless comment:
b = 56 # assigning b a value of 56
The next example shows a more helpful comment, instead,