In [1]:
class A:
    
    def __init__(self):
        self.hello = 'Hello'
        self.world = 'World'

In [2]:
a = A()

print(a.__dict__)


{'hello': 'Hello', 'world': 'World'}

In [3]:
class B(A):
    
    def to_dict(self):
        data = {}
        
        for k, v in self.__dict__.items():
            data[k] = [v]
        
        return data

In [4]:
b = B()

print(b.to_dict())


{'hello': ['Hello'], 'world': ['World']}

In [7]:
class C(B):
    
    @property
    def name(self):
        return '{0} {1}!'.format(self.hello, self.world)
    
    def to_dict(self):
        data = {}
        
        for k, v in self.__dict__.items():
            data[k] = [v]
        
        data['name'] = self.name
        
        return data

In [8]:
c = C()

print(c.to_dict())


{'hello': ['Hello'], 'world': ['World'], 'name': 'Hello World!'}

In [ ]: