Learning Circle : python #12 - ex44.py
This commit is contained in:
parent
54ba60818b
commit
a753cfeaac
7 changed files with 121 additions and 0 deletions
|
@ -1,3 +1,11 @@
|
|||
* 2020-06-17
|
||||
*** Python #11:
|
||||
**** DONE Lecture content
|
||||
CLOSED: [2020-06-17 수 22:24]
|
||||
- Same structure as "Python #2"
|
||||
- Exercise 44
|
||||
**** Lecture material
|
||||
- Available on https://cloud.ungleich.ch/s/435FyfrQyEq6oF3
|
||||
* 2020-06-15
|
||||
*** DONE Python #10:
|
||||
CLOSED: [2020-06-15 월 23:55]
|
||||
|
|
13
youngjin.han/python-the-hard-way/ex44a.py
Normal file
13
youngjin.han/python-the-hard-way/ex44a.py
Normal file
|
@ -0,0 +1,13 @@
|
|||
class Parent(object):
|
||||
|
||||
def implicit(self):
|
||||
print("PARENT implicit()")
|
||||
|
||||
class Child(Parent):
|
||||
pass
|
||||
|
||||
dad = Parent()
|
||||
son = Child()
|
||||
|
||||
dad.implicit()
|
||||
son.implicit()
|
15
youngjin.han/python-the-hard-way/ex44b.py
Normal file
15
youngjin.han/python-the-hard-way/ex44b.py
Normal file
|
@ -0,0 +1,15 @@
|
|||
class Parent(object):
|
||||
|
||||
def override(self):
|
||||
print("PARENT override()")
|
||||
|
||||
class Child(Parent):
|
||||
|
||||
def override(self):
|
||||
print("CHILD override()")
|
||||
|
||||
dad = Parent()
|
||||
son = Child()
|
||||
|
||||
dad.override()
|
||||
son.override()
|
17
youngjin.han/python-the-hard-way/ex44c.py
Normal file
17
youngjin.han/python-the-hard-way/ex44c.py
Normal file
|
@ -0,0 +1,17 @@
|
|||
class Parent(object):
|
||||
|
||||
def altered(self):
|
||||
print("PARENT altered()")
|
||||
|
||||
class Child(Parent):
|
||||
|
||||
def altered(self):
|
||||
print("CHILD, BEFORE PARENT altered()")
|
||||
super(Child, self).altered()
|
||||
print("CHILD, AFTER PARENT altered()")
|
||||
|
||||
dad = Parent()
|
||||
son = Child()
|
||||
|
||||
dad.altered()
|
||||
son.altered()
|
32
youngjin.han/python-the-hard-way/ex44d.py
Normal file
32
youngjin.han/python-the-hard-way/ex44d.py
Normal file
|
@ -0,0 +1,32 @@
|
|||
class Parent(object):
|
||||
|
||||
def override(self):
|
||||
print("PARENT override()")
|
||||
|
||||
def implicit(self):
|
||||
print("PARENT implicit()")
|
||||
|
||||
def altered(self):
|
||||
print("PARENT altered()")
|
||||
|
||||
class Child(Parent):
|
||||
|
||||
def override(self):
|
||||
print("CHILD override()")
|
||||
|
||||
def altered(self):
|
||||
print("CHILD, BEFORE PARENT altered()")
|
||||
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()
|
32
youngjin.han/python-the-hard-way/ex44e.py
Normal file
32
youngjin.han/python-the-hard-way/ex44e.py
Normal file
|
@ -0,0 +1,32 @@
|
|||
class Other(object):
|
||||
|
||||
def override(self):
|
||||
print("OTHER override()")
|
||||
|
||||
def implicit(self):
|
||||
print("OTHER implicit()")
|
||||
|
||||
def altered(self):
|
||||
print("OTHER altered()")
|
||||
|
||||
class Child(object):
|
||||
|
||||
def __init__(self):
|
||||
self.other = Other()
|
||||
|
||||
def implicit(self):
|
||||
self.other.implicit()
|
||||
|
||||
def override(self):
|
||||
print("CHILD override()")
|
||||
|
||||
def altered(self):
|
||||
print("CHILD, BEFORE OTHER altered()")
|
||||
self.other.altered()
|
||||
print("CHILD, AFTER OTHER altered()")
|
||||
|
||||
son = Child()
|
||||
|
||||
son.implicit()
|
||||
son.override()
|
||||
son.altered()
|
|
@ -1,3 +1,7 @@
|
|||
* 2020-06-17
|
||||
** note
|
||||
- ex44.py
|
||||
- none
|
||||
* 2020-06-15
|
||||
** note
|
||||
- ex43.py
|
||||
|
|
Loading…
Reference in a new issue