** * This article is from Udemy "[Introduction to Python3 taught by active Silicon Valley engineers + application + American Silicon Valley style code style](https://www.udemy.com/course/python-beginner/" Introduction to Python3 taught by active Silicon Valley engineers + application + American Silicon Valley style code style ")" It is a class notebook for myself after taking the course of. It is open to the public with permission from the instructor Jun Sakai. ** **
docstrings
def example_func(param1, param2):
"""Example function with types documented in the docstring.
Args:
param1 (int): The first parameter.
param2 (str): The second parameter.
Returns:
bool: The return value. True for success, False otherwise.
"""
print(param1)
print(param2)
return True
I prepared a sample function once. As a description of this sample, I would normally comment it out above the description line, In the case of a function, we promise to write it at the beginning of the inside.
docstrings
def example_func(param1, param2):
"""Example function with types documented in the docstring.
Args:
param1 (int): The first parameter.
param2 (str): The second parameter.
Returns:
bool: The return value. True for success, False otherwise.
"""
print(param1)
print(param2)
return True
print(example_func.__doc__)
result
Example function with types documented in the docstring.
Args:
param1 (int): The first parameter.
param2 (str): The second parameter.
Returns:
bool: The return value. True for success, False otherwise.
You can call ddocstrins for that function with the .__doc__
method.
docstrings
def example_func(param1, param2):
"""Example function with types documented in the docstring.
Args:
param1 (int): The first parameter.
param2 (str): The second parameter.
Returns:
bool: The return value. True for success, False otherwise.
"""
print(param1)
print(param2)
return True
help(example_func)
result
Help on function example_func in module __main__:
example_func(param1, param2)
Example function with types documented in the docstring.
Args:
param1 (int): The first parameter.
param2 (str): The second parameter.
Returns:
bool: The return value. True for success, False otherwise.
You can also call docstrings by using help
.
Recommended Posts