From a753cfeaac85f020eab1ca252e1c81c5a849ca40 Mon Sep 17 00:00:00 2001 From: Youngjin Han Date: Wed, 17 Jun 2020 22:25:02 +0900 Subject: [PATCH] Learning Circle : python #12 - ex44.py --- youngjin.han/learning-node02-2020.org | 8 ++++++ youngjin.han/python-the-hard-way/ex44a.py | 13 +++++++++ youngjin.han/python-the-hard-way/ex44b.py | 15 +++++++++++ youngjin.han/python-the-hard-way/ex44c.py | 17 ++++++++++++ youngjin.han/python-the-hard-way/ex44d.py | 32 +++++++++++++++++++++++ youngjin.han/python-the-hard-way/ex44e.py | 32 +++++++++++++++++++++++ youngjin.han/python.org | 4 +++ 7 files changed, 121 insertions(+) create mode 100644 youngjin.han/python-the-hard-way/ex44a.py create mode 100644 youngjin.han/python-the-hard-way/ex44b.py create mode 100644 youngjin.han/python-the-hard-way/ex44c.py create mode 100644 youngjin.han/python-the-hard-way/ex44d.py create mode 100644 youngjin.han/python-the-hard-way/ex44e.py diff --git a/youngjin.han/learning-node02-2020.org b/youngjin.han/learning-node02-2020.org index a30e0fc..0f5c6aa 100644 --- a/youngjin.han/learning-node02-2020.org +++ b/youngjin.han/learning-node02-2020.org @@ -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] diff --git a/youngjin.han/python-the-hard-way/ex44a.py b/youngjin.han/python-the-hard-way/ex44a.py new file mode 100644 index 0000000..f43251b --- /dev/null +++ b/youngjin.han/python-the-hard-way/ex44a.py @@ -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() diff --git a/youngjin.han/python-the-hard-way/ex44b.py b/youngjin.han/python-the-hard-way/ex44b.py new file mode 100644 index 0000000..331295f --- /dev/null +++ b/youngjin.han/python-the-hard-way/ex44b.py @@ -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() diff --git a/youngjin.han/python-the-hard-way/ex44c.py b/youngjin.han/python-the-hard-way/ex44c.py new file mode 100644 index 0000000..e935d04 --- /dev/null +++ b/youngjin.han/python-the-hard-way/ex44c.py @@ -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() diff --git a/youngjin.han/python-the-hard-way/ex44d.py b/youngjin.han/python-the-hard-way/ex44d.py new file mode 100644 index 0000000..032df1e --- /dev/null +++ b/youngjin.han/python-the-hard-way/ex44d.py @@ -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() diff --git a/youngjin.han/python-the-hard-way/ex44e.py b/youngjin.han/python-the-hard-way/ex44e.py new file mode 100644 index 0000000..084abe1 --- /dev/null +++ b/youngjin.han/python-the-hard-way/ex44e.py @@ -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() diff --git a/youngjin.han/python.org b/youngjin.han/python.org index b60fe35..9b082d6 100644 --- a/youngjin.han/python.org +++ b/youngjin.han/python.org @@ -1,3 +1,7 @@ +* 2020-06-17 +** note + - ex44.py + - none * 2020-06-15 ** note - ex43.py