1 단계: help()를 사용하여 문서 접근하기
docstring 은 모듈, 함수, 클래스 또는 메서드 정의에서 첫 번째 구문으로 나타나는 문자열 리터럴 (string literal) 입니다. 이는 코드가 무엇을 하는지 문서화하는 데 사용됩니다. Python 의 내장 함수인 help()는 이 문서를 깔끔하고 읽기 쉬운 형식으로 보는 데 탁월한 도구입니다. help() 함수는 대화형 사용 (interactive use) 을 위해 설계되었습니다.
내장 함수인 print() 함수의 문서를 보는 것으로 시작하겠습니다.
먼저, WebIDE 에서 터미널을 엽니다. 화면 상단의 Terminal 메뉴를 클릭하고 New Terminal을 선택하여 이 작업을 수행할 수 있습니다.
터미널에서 다음 명령어를 입력하고 Enter 키를 눌러 Python 대화형 셸 (interactive shell) 을 시작합니다.
python
Python 프롬프트 (>>>) 가 나타납니다. 이제 help() 함수를 사용하여 print()에 대한 정보를 얻습니다.
help(print)
터미널에 print 함수의 문서가 표시됩니다.
Help on built-in function print in module builtins:
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.
(END)
이 출력은 함수가 하는 일, 허용하는 매개변수 및 해당 기본값을 설명합니다. q 키를 눌러 도움말 뷰어 (help viewer) 를 종료하고 Python 프롬프트로 돌아갑니다.
이제 다음을 입력하여 Python 대화형 셸을 종료합니다.
exit()