When I do some code tests, there are some comments below the solution function like this:
"""
:type x: int
:rtype: int
"""
x
is my only input, so what does rtype stand for?
rtype: Return type. The type() function either returns the type of the object or returns a new type object based on the arguments passed.,If you need to check the type of an object, it is better to use the Python isinstance() function instead.
A Python docstring is a string used to document a Python module, class, function or method, so programmers can understand what it does without having to read the details of the implementation. Also, it is a common practice to generate online (html) documentation automatically from docstrings.
To avoid confusion:
type: Type of a parameter.
vartype: Type of a variable.
rtype: Return type.
It's the abbreviation for "return type".
See the Sphinx documentation for more information on field names and examples.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With