Python
[python] type 명령으로 class 선언하기
브라이언7
2016. 8. 28. 00:53
def __init__(self, name):
self.name=name
Person = type('Person',(object,),{"__init__":__init__})
p = Person("Jerry")
print(p.__dict__)
print(type(p))
print(Person.__class__)
<결과값>
{'name': 'Jerry'}
<class '__main__.Person'>
<class 'type'>
p의 type 값이 깔끔하게 class 'Person' 으로 나오지 않네요. 이유가 뭘까요??