-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinheritance.py
More file actions
41 lines (31 loc) · 908 Bytes
/
Copy pathinheritance.py
File metadata and controls
41 lines (31 loc) · 908 Bytes
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
# Defines class Parent.
class Parent(object):
# Defines function override().
def override(self):
print "PARENT override()"
# Defines function implicit().
def implicit(self):
print "PARENT implicit()"
# Defines function altered().
def altered(self):
print "PARENT altered()"
# Defines class Child. Inherits from Parent().
class Child(Parent):
# Overrides Parents function override().
def override(self):
print "CHILD override()"
# Overrides and alters Parents function altered().
def altered(self):
"""Dingle"""
print "CHILD, BEFORE PARENT altered()"
# Calls function altered() in super class (Parent).
super(Child, self).altered()
print "CHILD, AFTER PARENT altered()"
dad = Parent()
son = Child()
dad.implicit()
son.implicit()
dad.override()
son.override()
dad.altered()
son.altered()