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

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
主站蜘蛛池模板: 准格尔旗| 河北省| 南澳县| 梅州市| 且末县| 铜陵市| 安陆市| 湘潭市| 突泉县| 永定县| 小金县| 峨眉山市| 临安市| 新昌县| 渝北区| 卢龙县| 南宫市| 绍兴市| 新竹县| 海兴县| 玉溪市| 沈阳市| 南川市| 米脂县| 湖北省| 临夏县| 松滋市| 米泉市| 广平县| 汤阴县| 安乡县| 瑞丽市| 吴旗县| 巴林右旗| 嵊泗县| 抚松县| 杭州市| 高阳县| 海原县| 岳池县| 湘潭县|