I have a lot of classes, realizing some general tasks for different sites :
class AbstractCalculator :
pass # ... abstract methods lying here
class Realization1 (AbstractCalculator) :
@classmethod
def calculate_foo(...) :
# ...
@classmethod
def calculate_bar(...) :
# ...
class Realization2 (AbstractCalculator) :
@classmethod
def calculate_foo(...) :
# ...
@classmethod
def calculate_bar(...) :
# ...
Then i aggregating all those classes in one dictionary Now i introduce new different API :
class NewAbstractClass :
# ... introducting new API ...
@staticmethod
def adopt(old_class) :
# .. converting AbstractClass to NewAbstactClass
And then i use adopt() method like @decorator, to convert all old realizations to new.
But it all is very strange and complicated. Is there any better way to do this?
UPD @ColinMcGrath :
No I am asking definitely other.
My adopt() decorator is working, and I have no problems with it functioning (just, its body is not related to my question, so I have not provide it).
I think that hardcoding decoration of several tens of differnet classes right in their source code is not a best idea, and looking for canonical soulution.