파이썬 프로그램 요소의 대부분이 그렇듯이 클래스도 객체다. 파이썬 표준 라이브러리의 ‘내장
형
Built
-
in
Types
’ 장 안에 있는
4
.
13
절 ‘특별 메서드
Special
Attributes
’(
https://fpy.li/24-1
)에 문서
화된 것처럼, 모든 클래스에는 파이썬 데이터 모델이 정의한 수많은 속성이 있다. 그중 지금까
지
__mro__
,
__class__
,
__name__
을 여러 번 보았다. 그 외 다음과 같은 클래스 속성이 있다.
cls.__bases__
클래스의 슈퍼클래스들을 담은 튜플이다.
cls.__qualname__
클래스나 함수의 정규화된 이름
qualified
name
으로서, 모듈의 전역 범위에서부터 클래스 정의까
지의 경로를 점으로 구분한다. 클래스가 다른 클래스 안에 정의되었을 때 의미가 있다. 예를
들어
Ox
클래스(
https://fpy.li/24-2
)와 같은 장고 모델 클래스 안에
Meta
라는 내부 클
래스가 있다.
Meta
의
__qualname__
은
Ox.Meta
지만,
__name__
은
Meta
다. 이 속성은 ‘
PEP
3155
–클래스와 함수의 자격명
Qualified
name
for
classes
and
functions
’(
https://fpy.li/24-3
)에서
명시하고 ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month, and much more.