官术网_书友最值得收藏!

Chapter 3. When Objects Are Alike

In the programming world, duplicate code is considered evil. We should not have multiple copies of the same, or similar, code in different places.

There are many ways to merge pieces of code or objects that have a similar functionality. In this chapter, we'll be covering the most famous object-oriented principle: inheritance. As discussed in Chapter 1, Object-oriented Design, inheritance allows us to create is a relationships between two or more classes, abstracting common logic into superclasses and managing specific details in the subclass. In particular, we'll be covering the Python syntax and principles for:

  • Basic inheritance
  • Inheriting from built-ins
  • Multiple inheritance
  • Polymorphism and duck typing
主站蜘蛛池模板: 呼图壁县| 师宗县| 绥中县| 奇台县| 耿马| 大关县| 贵阳市| 拜泉县| 锡林浩特市| 耿马| 灵武市| 五常市| 荆州市| 大新县| 两当县| 沿河| 阿克陶县| 泽州县| 马鞍山市| 平和县| 阿巴嘎旗| 普洱| 阳山县| 惠来县| 临清市| 中牟县| 缙云县| 革吉县| 醴陵市| 绍兴县| 板桥市| 泸西县| 扎囊县| 浙江省| 宁蒗| 当涂县| 星座| 太康县| 尚志市| 古蔺县| 阿拉善左旗|