IndexedProperty#

class IndexedProperty(fget=None, fset=None, doc=None)[source]#

Bases: object

Based on the python implementation of the regular property() decorator. See for example: https://docs.python.org/3/howto/descriptor.html

The main tweak is __get__, where the above mentionned implementation directly calls the fget function. We instead return the class instance itself, where the parent class is now added to the class dict. Since the call is followed by brackets, immediatly the __getitem__ or __setitem__ methods are invoked. These methods are lacking the parent class but it now exists in the scope of the property instance. We can therefore call fget or fset with the parent class.

Methods#

getter#

getter(self, fget)#

setter#

setter(self, fset)#