Docstring Convention
Docstring 작성법
Parameter Explanation (매개변수 설명에 대한 관례)
Type 1
def complex(real=0.0, imag=0.0):
"""Form a complex number.
Keyword arguments:
real -- the real part (default 0.0)
imag -- the imaginary part (default 0.0)
"""
if imag == 0.0 and real == 0.0:
return complex_zero
...
Type 2
def fetch_words(url):
"""
url주소에서 파일을 가져와 단어 리스트를 반환합니다.
:param url: 불러올 url
:return:
"""
with urlopen(url) as story:
story_words = []
for line in story:
line_words = line.decode('utf-8').split()
for word in line_words:
story_words.append(word)
return story_words
Type 3
def complex(real=0.0, imag=0.0):
"""Form a complex number.
@param: real The real part (default 0.0)
@param: imag The imaginary part (default 0.0)
"""
if imag == 0.0 and real == 0.0: return complex_zero
...
Reference: python.org (URL)