Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Mixin:
- def __init__(self, *args, **kwargs):
- pass
- class Valuation:
- def __init__(self):
- self._qty = 0
- def qty(self):
- print('Valuation::qty')
- return self._qty
- class SubscriptionValuation:
- def __init__(self):
- self._qty = 0
- def qty(self):
- print('SubscriptionValuation::qty')
- return self._qty
- class Valuatable(Mixin):
- def __init__(self, *args, **kwargs):
- print("Enter Valuatable")
- super().__init__(**kwargs)
- self.valuation = (kwargs.get('valuation') or Valuation)()
- print("Leave Valuatable")
- def qty(self):
- return self.valuation.qty()
- class Summation:
- def __init__(self):
- self._total = 0
- def total(self):
- print('Summation::total')
- return self._total
- class SubscriptionSummation:
- def __init__(self):
- self._total = 0
- def total(self):
- print('SubscriptionSummation::total')
- return self._total
- class Summable(Mixin):
- def __init__(self, *args, **kwargs):
- print("Enter Summable")
- super().__init__(**kwargs)
- self.summation = (kwargs.get('summation') or Summation)()
- print("Leave Summable")
- def total(self):
- return self.summation.total()
- class Form(Valuatable, Summable):
- def __init__(self, *args, **kwargs):
- self.id = kwargs.get('id') or ''
- self.name = kwargs.get('name') or ''
- super().__init__(*args, **kwargs)
- f1 = Form(name='normal 1', valuation=Valuation)
- print(f1.qty())
- print(f1.total())
- f2 = Form(name='subscription 2', valuation=SubscriptionValuation, summation=SubscriptionSummation)
- print(f2.qty())
- print(f2.total())
Add Comment
Please, Sign In to add comment