@@ -194,14 +194,20 @@ really obvious cases, such as::
194
194
return a + b
195
195
196
196
The docstring should describe the function in a way that is easy to understand.
197
- Embedding the function's signature in the docstring is unnecessary because it
198
- can easily be obtained using the `inspect ` module, and doesn't provide much
199
- additional information.
197
+ For simple cases like trivial functions and classes, simply embedding the
198
+ function's signature (i.e. `add(a, b) -> result `) in the docstring is
199
+ unnecessary. This is because with Python's `inspect ` module, it is already
200
+ quite easy to find this information if needed, and it is also readily available
201
+ by reading the source code.
202
+
203
+ In larger or more complex projects however, it is often a good idea to give
204
+ more information about a function, what it does, any exceptions it may raise,
205
+ what it returns, or relevant details about the parameters.
200
206
201
207
For more detailed documentation of code a popular style is the one used for the
202
208
Numpy project, often called `Numpy style `_ docstrings. While it can take up a
203
- few more lines than usual , it allows the developer to include a lot more
204
- information about a method, function, or class. ::
209
+ few more lines the previous example , it allows the developer to include a lot
210
+ more information about a method, function, or class. ::
205
211
206
212
def random_number_generator(arg1, arg2):
207
213
"""
0 commit comments