Lets say I have a class representing a chemical compound
class Compound(networkx.Graph):
def __init__(self):
super(Compound, self).__init__()
And lets say that I want to add some extra functionality onto a chemical compound. It should probably inherit from Compound. But is it okay to just use it as a wrapper for Compound? For example
class Acid(Compound):
def __init__(self, compound, *other_data):
self.__dict__.update(compound.__dict__)
Basically, this class would just have pointers to the underlying class and then let me add functionality without having to copy things. Does this make sense? Is it reasonable? Am I even doing it right?
Aucun commentaire:
Enregistrer un commentaire