vscode "self" is not defined

问题遇到的现象和发生背景
用代码块功能插入代码,请勿粘贴截图
class animal(object):
    pass
class dog(animal):
    def __init__(self,name):
      self.name=name
    print(self.name)
运行结果及报错内容

"self" is not defined

python是一种强缩进的代码,正确的格式

class animal(object):
    pass
class dog(animal):
    def __init__(self,name):
      self.name=name
      print(self.name)

因为self是在init函数传入的,你必须在init里使用self
要么就定义其它类成员函数来使用self
而你的print直接写在了类下面,是个静态语句,这里没有self什么事