Function documentation
You should document your functions using a string at the beginning. This is called docstring:
def newton(f, x0): """ Newton's method for computing a zero of a function on input: f (function) given function f(x) x0 (float) initial guess on return: y (float) the approximated zero of f """ ...
When calling help(newton)
, you get this docstring displayed together with the call of this function:
Help on function newton in module __main__: newton(f, x0) Newton's method for computing a zero of a function on input: f (function) given function f(x) x0 (float) initial guess on return: y (float) the approximated zero of f
The docstring is internally saved as an attribute, ...
Get Scientific Computing with Python 3 now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.