Re: mro and super don't feel so pythonic
On Wed, 13 Apr 2022 at 15:02, Ganesh B
I hope nicer on the code text please.
Sure. Sorry about that. malmiteria's "lib" code is ``` class HighGobelin: def scream(self): print("raAaaaAar") class CorruptedGobelin(HighGobelin): def scream(self): print("my corrupted soul makes me wanna scream") super().scream() class ProudGobelin(HighGobelin): def scream(self): print("I ... can't ... contain my scream!") super().scream() ``` Best regards, Takuo Matsuoka
On Wed, Apr 13, 2022 at 9:21 AM Matsuoka Takuo
wrote: On Wed, 13 Apr 2022 at 04:28, malmiteria
wrote: Idk, what do you think?
I would need to see more examples to determine the limit of the current strategy for method resolution and super. For the example at hand, I can be happy with the following code as a lib user (using your lib code).
``` class Proud_base(HighGobelin): scream = HighGobelin.scream
class ProudGobelin_floating(ProudGobelin, Proud_base): pass
class HalfBreed(ProudGobelin_floating, CorrupteGobelin): def scream(self): if random.choices([True, False]): super(HalfBreed, self).scream() else: super(Proud_base, self).scream() ```
Best regards, Takuo _______________________________________________ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to python-ideas-leave@python.org https://mail.python.org/mailman3/lists/python-ideas.python.org/ Message archived at https://mail.python.org/archives/list/python-ideas@python.org/message/K63MS6... Code of Conduct: http://python.org/psf/codeofconduct/
participants (1)
-
Matsuoka Takuo