The cliche of python's private public property of is a must read

  • 2020-06-03 07:07:00
  • OfStack

In python, variables outside of in-class methods are called properties, and variables inside of in-class methods are called fields. Their private public access methods are similar.

class C:
  __name=" Private property "

  def func(self):

class sub_C(C):
  def info(self):
    print(C.__name)# Private fields of a parent class cannot be accessed in a derived class 

Methods and properties are accessed in a similar way, that is, private members can only be used within a class

Related articles: