Python docstring

What is docstring?

  • class, module, function, method μ •μ˜ μ‹œ μ‚¬μš©λ˜λŠ” python documentation string

  • python 객체의 _doc_ attribute λ˜λŠ” help() function을 톡해 μ ‘κ·Όν•  수 μžˆλ‹€.

  • 개발된 κΈ°λŠ₯을 μ‚¬μš©ν•˜κ±°λ‚˜ κ°œλ°œμ— κΈ°μ—¬ν•˜λŠ” λ‹€λ₯Έ κ°œλ°œμžλ“€μ˜ 이해λ₯Ό 돕기 μœ„ν•΄ μž‘μ„±λ˜λŠ” 주석

  • class, module, function, method의 첫 쀄에 μœ„μΉ˜ν•œλ‹€.

  • μ˜ˆμ‹œ: pandas

help(pandas)

Formats of docstring

One line docstring


Multi line docstring

  • roles

    • param: ν•„μˆ˜μ μœΌλ‘œ λͺ…μ‹œν•΄μ•Ό ν•œλ‹€.

    • type: sphinx data type for param

    • return: returned object

    • rtype: type of object retured


Google style


Numpy Style

Last updated