class car(object):
def read_spec_and_populate_db():
spec = read_from_file(spec.yaml)
populate_db(spec)
class awd(car):
super(awd, self).read_spec_and_populate_db()
def foo(self):
...
class fwd(car):
super(fwd, self).read_spec_and_populate_db()
def bar(self):
...
Class awd
and fwd
can be instantiated at different times or only one of them can be instantiated. Now, is there a way to restrict the base class method read_spec_and_populate_db() to be executed only once?
I did lookup in SO and found here. Wanted to see if there are any other option.
Edit: Not that I'm against it. I'm looking for ideas apart from using a flag. My current implementation is using a flag in the class.