我不知道是否有的Python:自.__ class__與類型(個體經營)
class Test(object):
def __init__(self):
print self.__class__.__name__
和
class Test(object):
def __init__(self):
print type(self).__name__
之間的差異?
是否有理由選擇其中一種?
(在我的使用情況下,我想用它來確定記錄器的名字,但我想這並不重要)
[類型(obj)和obj。\ _ \ _ class \ _ \ _之間的差異可能重複(http://stackoverflow.com/questions/1060499/difference-between-typeobj-and-obj-class) – user
@用戶,並且在某些情況下它們在Python 3中有區別(參見Flavien's [answer](http://stackoverflow.com/a/10633356/704244)) –