案例研究:用 Python 构建软件
Mark Pedigo, PhD
Principal Data Scientist

为新房确定按揭

+、-、*、/、**
在类之间重用代码
FinancialCalculator)继承父类(BasicCalculator)的全部功能class BasicCalculator:
def multiply(self, x, y):
result = x * y
return result
...
# Child of BasicCalculator
class FinancialCalculator(BasicCalculator):
def months_from_years(self, years):
# Inherits the .multiply() method
return self.multiply(years, 12)
...
doctest 与单元测试

案例研究:用 Python 构建软件