The first line of a docstring should contain a one-line description of the function, followed by a blank line.
A detailed description of arguments and behavior may follow.
In addition, the docstring may include a sample interactive session that calls the function
Tags
#python #sicp
Question
What might you include in a docstring?
Answer
?
Tags
#python #sicp
Question
What might you include in a docstring?
Answer
The first line of a docstring should contain a one-line description of the function, followed by a blank line.
A detailed description of arguments and behavior may follow.
In addition, the docstring may include a sample interactive session that calls the function
If you want to change selection, open original toplevel document below and click on "Move attachment"
Parent (intermediate) annotation
Open it Doctests. Python provides a convenient method for placing simple tests
directly in the docstring of a function. The first line of a docstring should
contain a one-line description of the function, followed by a blank line. A
detailed description of arguments and behavior may follow. In addition, the
docstring may include a sample interactive session that calls the function:
Original toplevel document
1.5 Control assert fib(50) == 7778742049, 'Error at the 50th Fibonacci number'
When writing Python in files, rather than directly into the interpreter, tests
are typically written in the same file or a neighboring file with the suffix
_test.py .
<span>Doctests. Python provides a convenient method for placing simple tests
directly in the docstring of a function. The first line of a docstring should
contain a one-line description of the function, followed by a blank line. A
detailed description of arguments and behavior may follow. In addition, the
docstring may include a sample interactive session that calls the function:
>>> def sum_naturals(n):
"""Return the sum of the first n natural numbers.
>>> sum_naturals(10)
55
>>> sum_n
Summary
status
not learned
measured difficulty
37% [default]
last interval [days]
repetition number in this series
0
memorised on
scheduled repetition
scheduled repetition interval
last repetition or drill
Details
No repetitions
Discussion
Do you want to join discussion? Click here to log in or create user.