2
为什么在类上设置描述符会覆盖描述符?
简单再现: class VocalDescriptor(object): def __get__(self, obj, objtype): print('__get__, obj={}, objtype={}'.format(obj, objtype)) def __set__(self, obj, val): print('__set__') class B(object): v = VocalDescriptor() B.v # prints "__get__, obj=None, objtype=<class '__main__.B'>" B.v = 3 # does not print "__set__", evidently does not trigger descriptor B.v # does not print anything, we overwrote the …