I have this
#!/usr/bin/env python
import math
class myclass(object):
def __init__(self,radius):
self.radius = radius
@property
def area(self):
print myclass.area, type(myclass.area)
return math.pi * ( self.radius ** 2)
@area.setter
def area(self,value):
print myclass.area, type(myclass.area)
pass
@area.deleter
def area(self):
print myclass.area, type(myclass.area)
del myclass.area
if __name__ == '__main__':
c = myclass(5.4)
c.area
c.area = 65
del c.area
This gives:
$ ./propertytest.py
<property object at 0x7ff0426ac0a8> <type 'property'>
<property object at 0x7ff0426ac0a8> <type 'property'>
<property object at 0x7ff0426ac0a8> <type 'property'>
Question:
Look at the way property object area has been accessed: c.area. area appears on the right side of the dot operator. Which special method is used by the property object to bind the class instance object with the right instance method and compute the result? How do properties work?
super(myclass, self).__init__().