Why do managed attributes just work for class attributes and not for instance attributes in python?

后端 未结 3 1278
野的像风
野的像风 2021-01-15 00:00

To illustrate the question check the following code:

class MyDescriptor(object):
  def __get__(self, obj, type=None):
    print \"get\", self, obj, type
             


        
3条回答
  •  萌比男神i
    2021-01-15 00:39

    I found _v of x1: It is in SomeClass1.__dict__['m']._v

    For the version suggested by S.Lott within the other answer: _v is in x1._v

提交回复
热议问题