On Wed, 13 Apr 2022 at 02:00, Matsuoka Takuo <motogeom...@gmail.com> wrote:
>
> Thanks for your answer.
>
> On Mon, 11 Apr 2022 at 00:46, malmiteria <martin.mi...@ensc.fr> wrote:
> >
> > There's a few problems, mainly, if you provide ProudGobelin and 
> > CorruptedGobelin as a lib author, you're very likely not to think of the 
> > HalfBreed use case, so the lib users wanting to create the HalfBreed class 
> > is bared from this solution, as it requires some work on ProudGobelin and 
> > CorruptedGobelin classes.

Actually, now I see.  It's the lib author's fault.  She went against
DRY in defining CorruptedGobelin and ProudGobelin as unrelated
subclasses of HighGobelin when they had a common structure, unless she
intended to make things like the "failing" version of HalfBreed easier
to create.  Otherwise, I think she should have done as follows, and
that's close to the solution I shared with you first.

```
class HighGobelin:
    def scream(self):
        print("raAaaaAar")

class SpeakingGobelin(HighGobelin):
    def scream(self):
        self._speak()
        super().scream()
    def _speak(self):
        return

class CorruptedGobelin(SpeakingGobelin):
    def _speak(self):
        print("my corrupted soul makes me wanna scream")

class ProudGobelin(SpeakingGobelin):
    def _speak(self):
        print("I ... can't ... contain my scream!")
```

Best regards,
Takuo
_______________________________________________
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-le...@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/KTXAPEKGLCP5LS3FJYQXBZIF7ZM5AERI/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to