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

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
主站蜘蛛池模板: 宜章县| 阳泉市| 麻江县| 井研县| 山丹县| 聂拉木县| 宜良县| 外汇| 荔浦县| 松桃| 房产| 天峻县| 阿鲁科尔沁旗| 裕民县| 南和县| 中西区| 西盟| 河池市| 竹溪县| 铜梁县| 普陀区| 沭阳县| 瓮安县| 咸阳市| 霸州市| 宜春市| 神农架林区| 碌曲县| 南木林县| 文山县| 龙陵县| 托克逊县| 澄江县| 怀宁县| 高要市| 乌审旗| 深圳市| 安岳县| 边坝县| 保康县| 乐昌市|