mercredi 16 août 2017

Unused argument in parent class, that is used in subclass. Bad policy?

I have a parent class with an unused argument in private function _f(i)

class Parent:
    def _f(i):
        return range(m)

    def g():
        for i in range(n)
            for j in _f(i)
                # do something

which is intended to be used in overriden method in subclasses

class Child:
    def _f(i):
        return range(i, m)

Having an unused argument feels ugly, but it saves me from code duplication in method g(). Is there any suggested way to avoid it, or should I leave it as it is?

Aucun commentaire:

Enregistrer un commentaire