Type Annotation (6) - Class
변수의 class 를 hint 로 제공할 경우, 단순히 class명을 변수명 옆에 써주면 된다. # class types class Hello: def world(self) -> int: return 7 # (1) 변수 정의 시 class hint myhello: Hello = Hello() # (2) 함수 인자에서 class hint def foo(ins: Hello) -> int: return ins.world() print(foo(hello)) # 7
개발/python-객체지향프로그래밍(OOP)
2022. 5. 23. 14:20