I am trying to find a "pythonic" approach to the following class organization:
I have a base class with properties initialized in its constructor, for example:
class Animal(object): def __init__(self, class_, species, is_domesticated): self.class_ = class_ self.species = species self.is_domesticated = is_domesticated
Then, when I subclass, I would like to “hard code” one or more of these properties, for example:
class Mammal(Animal): def __init__(self, species, is_domesticated): Animal.__init__(self, 'Mammal', species, is_domesticated)
Thus, a mammal is created in this way:
monkey = Mammal('Primate', false)
The problem is that I would like to use * args to leave only derived classes when changing the definition of the base class. Thus, the definition of a Mammal is as follows:
class Mammal(Animal): def __init__(self, *args): Animal.__init(self, *(args + (class_='Mammal',)))
Which (needless to say) looks awful. Some tips will be appreciated =)