I'm trying to subclass a dict object to create an object where some key values = 'property(fget, fset, fdel, doc)'. For some reason when I get the dictionary key a 'property object' is return instead of the result of the 'fget' function.
Code:
class mydict(dict):
def __init__(self, arg):
self['a'] = arg
self['b'] = property(self.get_b)
def get_b(self):
return self['a']
d = mydict(5)
print d['a'] # Returns 5
print d['b'] # Incorrect. Returns <property obeject>. Should return 5.
print d['b'].fget() # Returns 5. Correct
Comment