疑问在这段代码的注释里
class Dog:
kennel = 0
def __init__(self, breed):
self.breed = breed
Dog.kennel += 1
def __str__(self):
return self.breed + " says: Woof!"
class SheepDog(Dog):
def __str__(self):
return super().__str__() + " Don't run away, Little Lamb!"
class LowlandDog(SheepDog):
def __str__(self):
return Dog.__str__(self) + " I don't like mountains!"#这里用到Dog class的时候为什么要加self,其他像super().__str__()这种就不用加?
class GuardDog(Dog):
def __str__(self):
return super().__str__() + " Stay where you are, Mister Intruder!"
rocky = LowlandDog("Collie")
luna = GuardDog("Dobermann")
print(rocky.kennel) #这里的ouput是2,但我觉得是1,有点不太明白?
print(rocky)