# 매직 메서드(Magic Method) : __init__, __del__
---
## 1. 용어 정리
용어
| 설명
|
---|
****Magic Method****
| 특별한 의미를 가진 메서드, 이름이 `__이름__` 형태
파이썬의 내장 동작(연산자, 함수, 형 변환 등)을 클래스에서 재정의할 수 있게 해줌
|
****Dunder Method****
| "Double Underscore"의 줄임말로, `__`가 앞뒤로 붙은 메서드를 일컫는 별칭
|
예: `__init__` → "던더 이닛(dunder init)"
## 2. 대표적인 매직메서드
메서드
| 설명
| 예시
|
---|
`__init__(self, ...)`
| 생성자 (객체 생성 시 자동 호출)
| `p = Person("Alice")`
|
`__del__(self)`
| 소멸자 (객체 삭제 시 자동 호출)
| `del p`
|
`__new__(cls, ...)`
| 실제 객체 생성 (클래스 수준에서 실행)
| 고급 사용 시
|
- [https://dainwiki.com/books/python/page/init](https://dainwiki.com/books/python/page/init)
- [https://dainwiki.com/books/python/page/del](https://dainwiki.com/books/python/page/del)