Meta class가 왜 사용하는거지 라는 생각이 들었습니다. 언어의 구현 레벨을 어필할 수 있다.
# Ex1
# type 예제
class SampleA(): # Class == Object (문제는 있지만 그래도 파이썬 공식에서 하는 말)
pass
obj1 = SampleA() # 변수에 할당, 복사 가능, 새로운 속성, 함수의 인자로 넘기기 가능
# obj1 -> SampleA instance
# SampleA -> type meta class
# type -> type meta class
print('Ex1 > ', obj1.__class__) #Ex1 > <class '__main__.SampleA'>
print('Ex1 > ', type(obj1)) # Ex1 > <class '__main__.SampleA'>
print('Ex1 > ', obj1.__class__.__class__) # Ex1 > <class 'type'>
print('Ex1 > ', obj1.__class__ is type(obj1)) #True
print('Ex1 > ', obj1.__class__.__class__ is type(obj1).__class__) #True
type이란걸 통해서 가져오고 있었다. 우리가 class를 만들면 type이다.
모든 클래스의 메타는 type이다.
type클래스의 클래스를 찾아보니 그것 조차도 type이였다.
type은 수정할 수 없다.