Further information
Contents
Further information#
What formats can be used to write a docstring?#
The format used to write a docstring described in How to write a docstring is the one specified by the Numpy project.
Amongst other things you can see how to specify further functionality:
How to indicate if a parameter is optional.
How to specify what types of errors might be raised by a function.
How to specify when a function is a generator.
Are there tools available to assist with writing docstrings?#
The darglint
library can be used
to check if docstrings match a given format.
A part from removing duplicates and set operations what are they advantages to using set
?#
One valuable uses of set
is to efficiently identify if an element
is in a given iterable or not:
numbers = list(range(100000))
%timeit 100000 in numbers
737 μs ± 7 μs per loop (mean ± std. dev. of 7 runs, 1,000 loops each)
numbers = set(range(100000))
%timeit 100000 in numbers
22.9 ns ± 0.577 ns per loop (mean ± std. dev. of 7 runs, 10,000,000 loops each)