반응형
저는 현재 Python으로 시작하고 있으며 PHP 배경이 강하고 PHP에서는 javadoc
을 문서 템플릿으로 사용하는 습관을 가지고 있습니다.
javadoc
이 Python에서 docstring
문서로 자리를 잡았는지 궁금합니다. 여기에 확립 된 컨벤션 및 / 또는 공식 길드 라인은 무엇인가요?
예 : 파이썬 사고 방식에 맞추기에는 너무 정교하거나 가능한 한 간결하게해야합니까?
"""
replaces template place holder with values
@param string timestamp formatted date to display
@param string priority priority number
@param string priority_name priority name
@param string message message to display
@return string formatted string
"""
그리고 내가 너무 철저한 경우 대신 이와 같은 것을 사용해야합니까 (대부분의 문서가 __ doc __
메서드를 통해 인쇄되지 않는 경우)?
# replaces template place holder with values
#
# @param string timestamp formatted date to display
# @param string priority priority number
# @param string priority_name priority name
# @param string message message to display
#
# @return string formatted string
def format(self, timestamp = '', priority = '', priority_name = '', message = ''):
"""
replaces template place holder with values
"""
values = {'%timestamp%' : timestamp,
'%priorityName%' : priority_name,
'%priority%' : priority,
'%message%' : message}
return self.__pattern.format(**values)
해결 방법
귀하의 예는 다음과 같습니다.
"""Replaces template placeholder with values.
:param timestamp: formatted date to display
:param priority: priority number
:param priority_name: priority name
:param message: message to display
:returns: formatted string
"""
또는 유형 정보로 확장 :
"""Replaces template placeholder with values.
:param timestamp: formatted date to display
:type timestamp: str or unicode
:param priority: priority number
:type priority: str or unicode
:param priority_name: priority name
:type priority_name: str or unicode
:param message: message to display
:type message: str or unicode
:returns: formatted string
:rtype: str or unicode
"""
참조 페이지 https://stackoverflow.com/questions/5334531
반응형
'파이썬' 카테고리의 다른 글
파이썬 Python에서 jpg 파일을 표시하는 방법은 무엇입니까? (0) | 2020.10.07 |
---|---|
파이썬 Python에서 동적 / 런타임 메서드 생성 (코드 생성) (0) | 2020.10.07 |
파이썬 일련의 목록의 데카르트 곱을 얻습니까? (0) | 2020.10.07 |
파이썬 좋은 Python ORM 솔루션은 무엇입니까? (0) | 2020.10.07 |
파이썬 임시 파일에서 생성 및 읽기 (0) | 2020.10.07 |
댓글