렇게 다양하게 조합된 인수를 어노테이트하게 해준다. 함수의 반환형이 두 개 이상의 매개변수
의 자료형에 따라 달라질 때 특히 중요하다.
내장 함수
sum()
에 관해 알아보자.
help(sum)
이 출력한 도움말은 다음과 같다.
>>> help(sum)
sum(iterable, /, start=0)
Return the sum of a ‘start’ value (default: 0) plus an iterable of numbers
When the iterable is empty, return the start value.
This function is intended specifically for use with numeric values and may
reject non-numeric types.
내장 함수
sum()
은
C
언어로 작성되었지만,
typeshed
는
builtins.pyi
에 이 함수에 대해 다
음과 같은 오버로드된 자료형 힌트를 정의한다.
@overload
def sum(__iterable: Iterable[_T]) ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month, and much more.