I am trying to inherit a class constructor from a parent class. After trying several of the suggestions already on stack overflow I thought I'd ask a question myself to try and understand 1) why this code is wrong and 2) how to correct it?
The parent class:
class Submit_Copasi_Job(object):
'''
Submit a properly formatted copasi file to sun grid engine
'''
def __init__(self,copasi_file,report_name):
self.copasi_file=copasi_file
self.copasiML_str=self._read_copasiML_as_string()
self.report_name=report_name
self.submit_copasi_job_SGE()
def _read_copasiML_as_string(self):
'''
Read a copasiML file as string
'''
assert os.path.exists(self.copasi_file), "{} does not exist!".format(self.copasi_file)
with open(self.copasi_file) as f:
fle = f.read()
return fle
....
The child class (which tries to use the super(SubClass, self).__init__(...) but obviously I have something wrong)
class Submit_Copasi_Multijob(Submit_Copasi_Job):
def __init__(self):
super(Submit_Copasi_Multijob,self).__init__(copasi_file,report_name)
def test(self):
return self.copasi_file
Run code
fle='D:\\MPhil\\Model_Building\\Models\\TGFB\\Fli1_Models\\M7.cps'
s=Submit_Copasi_Multijob(fle,'rep.txt')
print s.test()
All my attempts so far have resulted in a similar error:
s=Submit_Copasi_Multijob(fle,'rep')
TypeError: __init__() takes exactly 1 argument (3 given)
__init__method ofSubmit_Copasi_Multijob... where arecopasi_fileandreport_namedefined? You forgot to add the arguments.