Notice
Recent Posts
Recent Comments
Link
«   2025/05   »
1 2 3
4 5 6 7 8 9 10
11 12 13 14 15 16 17
18 19 20 21 22 23 24
25 26 27 28 29 30 31
Tags
more
Archives
Today
Total
관리 메뉴

돌맹이

[Python] Docstring(문서화) 본문

programming/Python

[Python] Docstring(문서화)

오택 2022. 12. 27. 17:37

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