This will give you a more understanding of the differences:
Summary:
classA.one, self.class.one and type(obj).one are the same.
self.one and obj.one are the same and they are distinct per instance.
class classA:
one = "One"
def __init__(self, val):
self.__class__.one = val
def show(self, marker):
print("{}: self.one= {}, self.__class__.one= {}, classA.one= {}, type(self).one = {}".format(marker, self.one, self.__class__.one, classA.one, type(self).one))
one = classA('A')
one.show('One')
two = classA('B')
two.one = 'C'
two.show('Two')
print("{}".format(type(two).one))
three = classA('C')
classA.one = 'D'
three.one = 'E'
three.__class__.one = 'F'
three.show('Three')
two.show('Two')
one.show('One')
One: self.one= A, self.__class__.one= A, classA.one= A, type(self).one = A
Two: self.one= C, self.__class__.one= B, classA.one= B, type(self).one = B
B
Three: self.one= E, self.__class__.one= F, classA.one= F, type(self).one = F
Two: self.one= C, self.__class__.one= F, classA.one= F, type(self).one = F
One: self.one= F, self.__class__.one= F, classA.one= F, type(self).one = F
__class__
! You may cause code down the line that uses__class__
to break. – Pewee