fork download
  1. class Base(object):
  2.  
  3. def __init__(self, x):
  4. self.x = x if x else None
  5.  
  6. def start(self):
  7. pass
  8.  
  9. def stop(self):
  10. pass
  11.  
  12. def error(self, msg):
  13. raise Exception(msg)
  14.  
  15. def check(self):
  16. if self.x is None:
  17. self.error('wrong x')
  18.  
  19. class NewFeature(Base):
  20.  
  21. AUTO_PREPARE = False
  22.  
  23. def __init__(self, x, additional=False):
  24. super(Base, self).__init(x)
  25. self.additional = additional
  26.  
  27. def additional_start(self):
  28. if self.AUTO_PREPARE:
  29. self.custom = 'xxx'
  30. else:
  31. self.costom = None
  32.  
  33. def additional_stop(self):
  34. if self.AUTO_PREPARE:
  35. self.check()
  36. else:
  37. if self.costom is None:
  38. self.error('Nobody set custom')
  39.  
  40. def start(self):
  41. super(Base, self).start()
  42. if self.additional:
  43. self.additional_start()
  44.  
  45. def stop(self):
  46. if self.additional:
  47. self.additional_stop()
  48. super(Base, self).stop()
  49.  
Success #stdin #stdout 0.01s 7088KB
stdin
Standard input is empty
stdout
Standard output is empty