Type Annotation (9) - Generic Type
Generic Type A type that can be parameterized; typically a container class such as list or dict. Used for type hints and annotations. 파이썬 공식문서에서 는 generic type 을 위와 같이 설명하고 있다. 파이썬 내에서 Generic type class 는 type 을 파라미터화하여, 인자로 받을 수 있다. 인자로 받은 type 을 공유하는 지역변수 간에는 동일한 type 으로 표시될 수 있다. 이는 type hint와 annotation 을 위해 사용된다. 아래 예시를 보자. Robot class 를 정의할 때 T, K 라는 2개의 type 을 인자로 받는 Generic type 을 상속받는다..
개발/python-객체지향프로그래밍(OOP)
2022. 5. 25. 23:49