1DETECTED_WITCH = "Burn her!"
2FALSE_POSITIVE = "No, but it's a pity, cuz she looks like a witch!"
3
4def logic_mixin_factory(mass, mass_attr_name, material,
5 material_attr_name, float_method_name):
6 class MixinWitch:
7
8 checkmass = (mass_attr_name, mass)
9 checkmats = (material_attr_name ,material)
10 checkmethod = float_method_name
11
12 def is_a_witch(self):
13 for key, value in self.__dict__.items():
14 if key == self.checkmass[0] and value == self.checkmass[1]: return DETECTED_WITCH
15 if key == self.checkmats[0] and value == self.checkmats[1]: return DETECTED_WITCH
16
17 for att in dir(self):
18 if callable(getattr(self, att)) and att == self.checkmethod: return DETECTED_WITCH
19
20 return FALSE_POSITIVE
21
22 return MixinWitch
.
----------------------------------------------------------------------
Ran 1 test in 0.000s
OK
10.11.2023 09:15