OO isn't my strongest suit, so please bear with me. I want to design a class structure something like this:
class Mammal(object):
def __init__(self):
super(Mammal, self).__init__()
self.dna_sequence = self.sequence_dna()
def sequence_dna(self):
blood_sample = 42
# Code goes here to sequence the mammal's DNA - may take a while.
Then, over in another class, I want to inherit from Mammal:
class Human(Mammal):
super(Human, self).__init__()
self.dna_sequence = self.sequence_dna()
def sequence_dna(self):
blood_sample = 43
# use blood sample and Human algo to sequence it.
So here's where I'm stuck. When I create the Human object, I don't want it to go and do the DNA sequencing, cause that takes a while. But I need the Human object to have the dna_sequence attribute so that I can do the sequencing later. Is the solution, to set the attribute in the init method, but to set it to None until the sequence_dna method is called? Seems kludgy, especially since I have many variables, all of which will depend on the outcome of the DNA sequencing and thus be set to None.
I feel like I'm missing a piece of the puzzle...