Sample code with inheritance that works as expected.
class Animal:
def action(self, value_1, p=None):
print ('Parent action %d %d' % (value_1, p))
return value_1 + 1 + p
class Dog(Animal):
def action(self, value):
print ('Dog action in child')
return super(Dog, self).action(value, 1)
print(Dog().action(10))
Following is another example of inheritance where the following error is thrown.
AttributeError: 'super' object has no attribute 'compare_files'
class FileCompare:
def compare_files(self, actual_filename, ref_filename, field_to_skip=None):
return True
class MetaFileCompare(FileCompare):
def compare_files(self, actual_file, ref_file):
return super(FileCompare, self).compare_files(actual_file, ref_file,
0)
class WorkerFileCompare(FileCompare):
def compare_files(self, actual_file, ref_file):
return super(FileCompare, self).compare_files(actual_file, ref_file,
5)
print (WorkerFileCompare().compare_files('a', 'b'))
Code is almost same except for class name, method name and return type. Sounds like am missing something very silly. There are no typo errors. Can you please provide some pointers?