비정적 타입의 키워드 인수
- 이벤트 발생 시각까지 포함해 로깅 메시지를 출력하는 예제
datetime.now
는 함수를 정의할 때 딱 한 번만 실행: 타임스탬프 동일하게 출력
- 이 코드를 담고 있는 모듈이 로드된 후에는 기본 인수인
datetime.now
를 다시 평가하지 않음
- 결과가 기대한 대로 나오게 하려면 기본값을
None
으로 설정하고 docstring
(문서화 문자열)으로 실제 동작을 문서화하는 것이 관례
- “WAY 49. 모든 함수, 클래스, 모듈에 docstring을 작성하자” 참고
- 코드에서
None
이 나타나면 알맞은 기본값을 할당하면 됨
Comments