ch11-24: clean up by @eumiro & sync with Atlas

This commit is contained in:
Luciano Ramalho
2021-02-14 20:58:46 -03:00
parent 03ace4f4ae
commit 47cafc801a
143 changed files with 21692 additions and 63 deletions

View File

@@ -0,0 +1,4 @@
Sample code for Chapter 14 - "Inheritance: for good or for worse"
From the book "Fluent Python, Second Edition" by Luciano Ramalho (O'Reilly, 2021)
https://learning.oreilly.com/library/view/fluent-python-2nd/9781492056348/

27
14-inheritance/diamond.py Normal file
View File

@@ -0,0 +1,27 @@
class A:
def ping(self):
print('ping:', self)
class B(A):
def pong(self):
print('pong:', self)
class C(A):
def pong(self):
print('PONG:', self)
class D(B, C):
def ping(self):
super().ping()
print('post-ping:', self)
def pingpong(self):
self.ping()
super().ping()
self.pong()
super().pong()
C.pong(self)