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

Chapter 3. Syntax Best Practices – above the Class Level

We will now focus on syntax best practices for classes. It is not intended to cover design patterns here, as they will be discussed in Chapter 14, Useful Design Patterns. This chapter gives an overview of the advanced Python syntax to manipulate and enhance the class code.

Object model evolved greatly during history of Python 2. For a long time we lived in a world where two implementations of the object-oriented programming paradigm coexisted in the same language. These two models were simply referred to as old-style and new-style classes. Python 3 ended this dichotomy and only model known as new-style classes is available to the developers. Anyway, it is still important to know how both of them worked in Python 2 because it will help you in porting old code and writing backwards compatible applications. Knowing how the object model changed will also help you in understanding why it is designed that way right now. This is the reason why the following chapter will have a relatively large number of notes about old Python 2 features despite this book targets the latest Python 3 releases.

The following topics will be discussed in this chapter:

  • Subclassing built-in types
  • Accessing methods from super classes
  • Using properties and slots
  • Metaprogramming
主站蜘蛛池模板: 彩票| 永平县| 商都县| 格尔木市| 曲阜市| 陇西县| 竹北市| 尼勒克县| 沙湾县| 富蕴县| 永胜县| 大港区| 嘉峪关市| 福海县| 普宁市| 仙居县| 突泉县| 潼南县| 利辛县| 津南区| 宁津县| 娄烦县| 镇宁| 平凉市| 磐安县| 车险| 定西市| 南平市| 贵德县| 通州区| 青冈县| 琼结县| 万荣县| 洪湖市| 广河县| 收藏| 如东县| 公安县| 瑞丽市| 石狮市| 呼伦贝尔市|