笨方法学python中强调:
Most of the uses of inheritance can be simplified or replaced with composition, and multiple inheri- tance should be avoided at all costs.
继承的大部分用途可以简化或者用组合替换,并且应该不惜一切代价避免多次继承。
类的第一种用法:
implicit inheritance
隐形继承
第二种:
override
重写
第三种:
Alter Before or After
就是可以选择到底用子类重写的函数,还是使用基类的函数。
出现错误
出现错误,不知道哪里错了。
把输入参数修改到实例化对象后,正确运行了:
正确
super()函数可以把子类从重写的函数中拯救出来,使用原来的父类的函数。