python - TypeError: __init__() takes exactly 4 arguments (1 given) -


i need , have following classes in python inheritance , have error:

class human:      def __init__(self,name,surname,age):         self.name = name         self.surname = surname         self.age = age      def getname(self):         return self.name      def getsurname(self):         return self.surname      def setname(self, name):         self.name = name      def setsurname(self, surname):         self.surname = surname      def setage(self, age):         self.age = age      def getage(self):         return self.age     pass 

and:

from human import human  class student(human):      def __init__(self,name,surname,age,file):         human().__init__(self,name, surname, file)         self.file = file      def getfile(self):         return self.file      def setfile(self, file):         self.file = file      pass 

when instantiate me following error

from student import student student1 = student("jhon", "santana", "20", "111000") 

error:

human().__init__(self, name, surname, age) typeerror: __init__() takes 4 arguments (1 given) 

which cause of error? thanks...

human().__init__(self,name, surname, age) 

thats not how create instance of class

you should do:

human.__init__(self,name, surname, age) 

without () .otherwise try create instance of in human()


Comments