While I managed to construct a manageable answer to my question:
class A(object):
def __init__(self, B, *args, **kwargs):
''' Modifies input class B, rendering it a super class of class A'''
_parent = {}
method_list = [func for func in dir(self) if callable(getattr(self, func))]
for att in B.__dir__():
_parent[att] = B.__getattribute__(att)
if att not in method_list:
try:
self.__setattr__(att, B.__getattribute__(
att))
except:
pass
B.__init__(self, *args, **kwargs)
self.__parent__ = _parent
#add self variables here
def func(self):
#modify inherited func here
self.__parent__['func']()
#modify inherited func here
I do not know if it always works and I would like to know if someone else has a better solution to this (rather trivial for other languages) question. Also, this solution is only applicable in Python3 and above (otherwise inspect module is needed for the replacement of the callable
part)