728x90
반응형
이전에는 클래스 내의 메소드를 많이 알지 못했다.
__init__ 하나 알고 있었는데
이번 기회에 많은 것을 알 수 있었다.
- __new__(cls, ...)
class inch(float):
#"Convert from inch to meter"
def __new__(cls, arg=0.0):
return float.__new__(cls, arg*0.0254)
#print inch(12)
#0.3048
- __del__(self) 문서 삭제할 때 사용
- __eq__(self,other) 항등 연산자에 대하여 작용
- __lt__(self, other) 문서의 크기가 작을 때 사용
- __gt__(self, other) 문서의 크기가 클 때 사용
- __le__(self,other) 문서의 크기가 작거나 같을 때 사용
- __ge__(self, other) 문서의 크기가 크거나 같을 때 사용
728x90
반응형
'CS 지식 정리 > 개발기록' 카테고리의 다른 글
OMP: Error #15: Initializing libiomp5md.dll, but found libiomp5md.dll already initialized (0) | 2023.11.06 |
---|---|
ERROR: Cannot find command 'git' - do you have 'git' installed and in your PATH? (0) | 2023.10.18 |
[python] AI class 기본 메서드 __init__, __len__, __getitem__ (0) | 2023.08.20 |
[SSAFY] 스타트 캠프 레드브릭 활동 (0) | 2023.07.11 |
[SSAFY] 스타트 캠프 레고 스파이크 활동 (0) | 2023.07.11 |
댓글