python: are property fields being cached automatically?

后端 未结 8 737
离开以前
离开以前 2020-12-14 15:20

My question is are the following two pieces of code run the same by the interpreter:

class A(object):
  def __init__(self):
     self.__x = None

  @property         


        
8条回答
  •  北荒
    北荒 (楼主)
    2020-12-14 16:17

    No, the getter will be called every time you access the property.

提交回复
热议问题