类中的继承在Python 2.7中不起作用

类中的继承在Python 2.7中不起作用,python,class,oop,inheritance,Python,Class,Oop,Inheritance,我正在努力提高对Python 2.7中OOP的理解(在我的大学课程中使用)。我的目标是使用子类打印结果。然而,我不断得到下面的错误,不知道如何修复它,为什么它弹出 有谁能告诉我如何修复此代码以及我做错了什么 错误: Traceback (most recent call last): File "*******"", line 36, in <module> print_grades = CreateReport(ReadFile) TypeError: __init__() tak

我正在努力提高对Python 2.7中OOP的理解(在我的大学课程中使用)。我的目标是使用子类打印结果。然而,我不断得到下面的错误,不知道如何修复它,为什么它弹出

有谁能告诉我如何修复此代码以及我做错了什么

错误:

Traceback (most recent call last):
File "*******"", line 36, in <module>
print_grades = CreateReport(ReadFile)
TypeError: __init__() takes exactly 1 argument (2 given)

在构造
CreateReport
时,不需要将
ReadFile
作为参数传递…!关于Python 2.7,目前需要了解的最重要的一点是,我在课程中肯定会指出:@deceze调整代码会导致以下错误:TypeError:unbound method data_to_list()必须以ReadFile instance作为第一个参数调用(没有得到任何结果)class CreateReport():def u u u u(self):(self,
ReadFile
是一个旧式类,因为它没有从
对象
显式继承。多年来,旧式类一直被认为是过时的,由于向后兼容的原因,只有在Python2的更高版本中仍然支持旧式类。Python3根本没有旧式的类,每个类都是一个新样式的类,不管它是否显式地继承自
对象
# Constants
input_file = 'grades1.in.txt'

class ReadFile():

def __init__(self):
    self.text_file =''

    def read_file(self, file):
        self.text_file = open(file)

    def data_to_list(self):
        self.list_grades = []
        for x in self.text_file:
            output = x.strip("\n").split("\n")
            temp_list = []
            for y in output:
                temp_list.append(y)
            self.list_grades.append(temp_list)
         return self.list_grades

class CreateReport(ReadFile):
    def __init__(self):
        # ReadFile.__init__(self)
        pass

    def print_list(self):
        data = ReadFile.data_to_list()
        print data

# start_program(input_file)
print_grades = CreateReport(ReadFile)
print_grades.print_list()