Python “protected” attributes

后端 未结 7 1326
迷失自我
迷失自我 2020-12-13 03:39

How do I access a private attribute of a parent class from a subclass (without making it public)?

7条回答
  •  春和景丽
    2020-12-13 04:35

    Make an accessor method, unless I am missing something:

    def get_private_attrib(self):
      return self.__privateWhatever
    

提交回复
热议问题