added chapter map to README

This commit is contained in:
Luciano Ramalho
2019-04-06 07:11:08 -03:00
parent 707ac3ae29
commit 5257010c7f
208 changed files with 45 additions and 12 deletions

View File

@@ -0,0 +1,4 @@
Sample code for Chapter 12 - "Inheritance: for good or for worse"
From the book "Fluent Python" by Luciano Ramalho (O'Reilly, 2015)
http://shop.oreilly.com/product/0636920032519.do

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)