What is the standard way for writing default values in a python docstring?
I have a function with parameters set to default values. I'm using a NumPy-style docstring, but I've seen the default values written elsewhere. What is the commonly accepted placement for writing "default" in the docstring?
def some_func(a_num=None, a_string=None):
''' A function that does something special.
Parameters
==========
a_num : int, default 100 # is it written here?
An important number.
a_string : str, default 'foo'
A useful string. Default is 'foo'. # or here?
'''
Solution 1:
If you read further in the document you linked it looks like there's no one standard style:
Optional keyword parameters have default values, which are displayed as part of the function signature. They can also be detailed in the description:
Description of parameter `x` (the default is -1, which implies summation over all axes).
When a parameter can only assume one of a fixed set of values, those values can be listed in braces, with the default appearing first:
order : {'C', 'F', 'A'} Description of `order`.
I would recommending picking a style for your own project and sticking to it.