돌맹이
[Python] Docstring(문서화) 본문
Docstring은 class, method 등의 사용법이나 이해를 돕기위해 달아 놓은 코드로 ''' 또는 """ 사이에 작성한다.
class, method 등의 선언 바로 뒤에 작성하는 것을 원칙으로 한다.
예시)
def add(num1, num2):
"""
Add up two integer numbers.
This function simply wraps the ``+`` operator, and does not
do anything interesting, except for illustrating what
the docstring of a very simple function looks like.
Parameters
----------
num1 : int
First number to add.
num2 : int
Second number to add.
Returns
-------
int
The sum of ``num1`` and ``num2``.
See Also
--------
subtract : Subtract one integer from another.
Examples
--------
>>> add(2, 2)
4
>>> add(25, 0)
25
>>> add(10, -10)
0
"""
return num1 + num2
참조: https://pandas.pydata.org/docs/development/contributing_docstring.html
'programming > Python' 카테고리의 다른 글
[Python] Pandas (0) | 2022.12.29 |
---|---|
[Python] NumPy(넘파이) (0) | 2022.12.28 |
[Python] 문자열 포매팅(String Formatting) (0) | 2022.12.27 |
[Python] Dictionary 자료형 (0) | 2022.12.27 |