Type Hints in Python
์ค๋ ์๋ก ์๊ฒ๋์ด์ ์ ๋ฆฌ!
Reference: python docs
Before getting started
Python runtime์ function์ด๋ variable์ type annotation์ ๊ฐ์ ์ ํ์ง ์๋๋ค
IDE๋ type checker๋ฅผ ์ด์ฉํด์ผ ํ์ธ ํ ์ ์๋ค
Type hint๋ฅผ ์ ๊ณตํด์ method ์ฌ์ฉ ์ type์ ์๋ ค์ค ์ ์๋ค
Function Annotations
Function annotation์ Parameter ์ return value ์์ ์ฌ์ฉ๋ ์ ์๋๋ฐ ๊ฐ์ ๋ ์๋๋ค!
Function annotation์ ํ์ฉํ์ฌ typechecking ์ ์ ๊ณตํ ์ ์๋ค
๋จ, Lambda๋ annotation์ ์ง์ํ์ง ์๋๋ค!
Syntax
1. Parameters
ex1) parameter
ex2) excess parameter ( *args
, **kwargs
)
2. Return Values
ex)
+
Type aliases
: ์ถ๊ฐ๋ก alias๋ฅผ ํ์ฉํ ์๋ ์๋ค!
ex)
Last updated
Was this helpful?