I made a program named as a title.py inside it used Inheritance , now I want to Extend the Parent Class in another program(file also) but having an Error lets check ,my code
1.first file title .py class global Studentdatabase: def __init__(self,name,age,standard,place,dateofbirth,sex): self.name=name self.age=age self.standard=standard self.place=place self.dateofbirth=dateofbirth self.sex=sex print 'Initalizing',self.name def tell(self): 'TELL DETAILS' print 'NAME,AGE,STANDARD,PLACE,DATEOFBIRTH,SEX',self.name ,self.age,self.standard,self.place,self.dateofbirth,self.sex class Teacher(Studentdatabase): def __init__(self,name,age,standard,place,dateofbirth,sex,salary): Studentdatabase.__init__(self,name,age,standard,place,dateofbirth,sex) self.salary=salary print 'name is ',self.name def tell(self): Studentdatabase.tell(self) print 'The salary is',self.salary class Student(Studentdatabase): def __init__(self,name,age,standard,place,dateofbirth,sex,marks): Studentdatabase.__init__(self,name,age,standard,place,dateofbirth,sex) self.marks=marks print 'The name',self.name def tell(self): Studentdatabase.tell(self) print 'The marks is',self.marks t=Teacher('Mr.sudhanshu',21,'B.E','Jaipur','12/02/1986','MALE',21000) s=Student('Anirudh',19,'Engineering','Delhi','12/3/1989','MALE',65) members=[t,s] for member in members: member.tell() 2.Now another file in which I want to extend that same parent class is here .First code running successfully but in another one having problem 'This another source code will represent the new Entry of database' import title class Newstudent(Studentdatabase): def __init__(self,name,age,standard,place,dateofbirth,sex,marks): Studentdatabase.__init__(self,name,age,standard,place,dateofbirth,sex) self.marks=marks print 'The new data base has name of new students',self.name def tell(self): Studentdatabase.tell(self) print 'The marks of the student is',self.marks s1=Newstudent('Rajiv',21,'M.B.A','MUMBAI','12 JAN,1987','MALE',267) s2=Newstudent('VIKASH',22,'M.B.A','DELHI','12 JAN 1985','MALE',234) s3=Newstudent('SAURAV',23,'B.TECH','BIHAR','12 JAN 1984','MALE',233) new=[s1,s2,s3] for newstudent in new: newstudent.tell() Now tell me that how I can extend it regards sudhanshu :)
_______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor