While learning about descriptors in Python, I tried the following code:
class D(object) :
def __init__(s) :
s.a = ''
def __get__(s, ins, own) :
print 'desc get'
return s.a
def __set__(s, ins, val) :
print 'desc set'
s.a = val
class C(object) :
d = D()
C.d = 'danger'
c = C()
c.d = 'some str'
Why is it that when C.d = 'danger'
is executed, the descriptor is removed from C.__dict__
?