I have this code for testing the data descriptors
class DataDescriptor(object):
def __init__(self):
self.value = 1990
def __get__(self,obj,cls):
print "__get__ in Data descriptor"
return self.value
def __set__(self,obj,value):
self.obj = value
print "__set__ in Non Data Descriptor"
def __del__(self,obj):
print "__del__ in Non Data Descriptor"
del self.obj
class NonDataDescriptor(object):
def __get__(self,obj,cls):
print "__get__ in Non Data descriptor"
class C(object):
dd = DataDescriptor()
ndd =NonDataDescriptor()
def __init__(self):
self.__value = 1
cobj = C()
cobj.dd
When i execute that , then i ca only see the print statement but i can’t see the actual value i am retirung in my get function
My output is this only
__get__ in Data descriptor
You didn’t print the return value. So, you didn’t see it.
You need to do: –