Hi this is newbie in python, I want write a prioritized decorator which will decide which class instance has to be instantiated depending upon the priority value passed to the decorator.
# abstract class
class Base:
def method1(self):
pass
@deco(priority=1)
class A(Base):
def method1(self):
pass
@deco(priority=3)
class B(Base):
def method1(self):
pass
@deco(priority=2)
class C(B):
def method1(self):
pass
def return_class_obj():
# this method will return the object based upon the priority of the
# class passed through decorator
It seems that you need something like this:
This will output
ABC