using docstring in python

Solutions on MaxInterview for using docstring in python by the best coders in the world

showing results for - "using docstring in python"
Regina
30 Mar 2020
1#A docstring is a string literal that occurs as the first statement in a module, 
2#function, class, or method definition. Such a docstring becomes the __doc__ special 
3#attribute of that object. 
4#They serve as documentation or explanation to a statement in a function, class or 
5#method definition. They are kept in a triple quotation mark.
6
7
8def complex(real=0.0, imag=0.0):
9    """Form a complex number.
10
11    Keyword arguments:
12    real -- the real part (default 0.0)
13    imag -- the imaginary part (default 0.0)
14    """
15    if imag == 0.0 and real == 0.0:
16        return complex_zero
17    ...
18