how to acess object of both parrents class python in single self

Solutions on MaxInterview for how to acess object of both parrents class python in single self by the best coders in the world

showing results for - "how to acess object of both parrents class python in single self"
Émilie
19 Apr 2017
1
2		
3#definition of the class starts here  
4class Person:  
5    #defining constructor  
6    def __init__(self, personName, personAge):  
7        self.name = personName  
8        self.age = personAge  
9  
10    #defining class methods  
11    def showName(self):  
12        print(self.name)  
13  
14    def showAge(self):  
15        print(self.age)  
16  
17    #end of class definition  
18  
19# defining another class  
20class Student: # Person is the  
21    def __init__(self, studentId):  
22        self.studentId = studentId  
23  
24    def getId(self):  
25        return self.studentId  
26  
27  
28class Resident(Person, Student): # extends both Person and Student class  
29    def __init__(self, name, age, id):  
30        Person.__init__(self, name, age)  
31        Student.__init__(self, id)  
32  
33  
34# Create an object of the subclass  
35resident1 = Resident('John', 30, '102')  
36resident1.showName()  
37print(resident1.getId())  
38