-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinheritance.py
More file actions
53 lines (51 loc) · 1.42 KB
/
inheritance.py
File metadata and controls
53 lines (51 loc) · 1.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#!/usr/bin/python
#MyMother=mom()
#print id(MyMother)
#help(mom)
# def talk(self):
# print "speak softly"
class Dad():
def talk(self):
print "speak politely"
def __init__(self):
print "Object of class dad constructed"
def __del__(self):
print "Object of class Dad destroyed"
class PGM():
def TalkPGM(self):
print "tell stories"
def __init__(self):
print "Object of class PGM Constructed"
class PGF():
def TalkPGF(self):
print "Encourage"
def Talk(self):
print "PGF Speaking"
def __init__(self):
print "Object of class PGF Constructed"
class MGM():
def Talk(self):
print "speak softly"
def __init__(self):
print "Object of class MGM constructed"
class MGF():
def Teach(self):
print "teach values"
def __init__(self):
print "Object of class MGF Constructed"
class mom(MGM,MGF):
x=10;y=20
def walk(self):
print "walk Elegantly"
print id(self)
def sum(self,a,b):
return(a+b+self.x+self.y)
def __init__(self):
print "Object of class Mom"
class infant(mom,Dad):
pass
Baby=infant()
print dir(Baby)
Baby.walk()
Baby.talk()
print Baby.sum(10,20)