help 함수
파이썬에서는 API 문서를 찾아볼 필요도 없이 hlep 함수로 어떤 값을 매개변수로 받는지
혹은 어떤 값을 반환하는지 알 수 있다.
유닉스의 man 명령과 유사하다.
help( print)
Help on built-in function print in module builtins:
print(...)
print(value, ..., sep=' ', end='\n', file=sys.stdout, flush=False)
Prints the values to a stream, or to sys.stdout by default.
Optional keyword arguments:
file: a file-like object (stream); defaults to the current sys.stdout.
sep: string inserted between values, default a space.
end: string appended after the last value, default a newline.
flush: whether to forcibly flush the stream.
|
__doc__ 속성
파이썬은 모든 것이 객체이다.
__doc__ 속성은 모든 객체의 부모인 object 에 포함된 기본적인 속성으로
주로 객체에 대한 설명을 적는데 사용한다.
사용법은 다음과 같다.
def plus(a, b):
return a + b
plus.__doc__ = """
Description : Return the sum of parameter a, b
Parameter : a, b
Return : a + b
"""
help(plus)
Help on function plus in module __main__:
plus(a, b)
Description : Return the sum of parameter a, b
Parameter : a, b
Return : a + b
|
'Script > Python' 카테고리의 다른 글
16. Class (0) | 2020.01.15 |
---|---|
15. Generic Operation With Containers (0) | 2020.01.15 |
13. pass (0) | 2020.01.15 |
11. Conditional Statements (0) | 2020.01.15 |
10. Statement Blocks (0) | 2020.01.15 |