概述

1. changing the string representation of instances 修改实例的字符串表示

2. customizing string formate 自定义字符串的输出格式

3. making objects support the context-management protocol 让对象支持上下文管理协议

4. saving memory when creating a large number of instances 但创建大量实例时如何节省内存

5. encapsulting names in a classes 将名称封装到类中

6. creating managed attributes 创建可管理的属性

7. calling a method on a parent class 调用父类的方法

8. extending a property in subclass 在子类中扩展属性

9. creating a new kind of class or instance attribute 创建一种新形式的类属性或实例属性

10. using lazily computed properties 让属性具有惰性求值的能力

11. simplifying the initialization of data structure 简化数据结构的初始化过程

12. defining an interface or abstract base class 定义一个接口或抽象基类

13. implementing a data model or type system 实现一种数据模型或类型系统

14. implementing custom containers 实现自定义容器

15. delegating attribute access 委托属性的访问

16. define more than one constructors in a class 在类中定义多个构造函数

17. creating an instance without involking __init__ 不通过调用__init来创建函数

18. extending classes with mixins 用mixin技术来扩展类定义

19. implementing stateful objects or state mechines 实现带有状态的对象或状态机

20. calling a method on an object given the name as a string 调用对象上的方法, 方法名以字符串形式给出

21. implementing the visitor pattern 实现访问者模式

22. implementing the visitor pattern without recursion 实现非递归的访问者模式

23. managing memory in cyclic data structures 在环状数据结构中管理内存

24. making classes support comparison operations 让类支持比较操作

25. creating cached instances 创建缓存实例

posted on 2018-01-24 22:49  lg100_lg100  阅读(84)  评论(0编辑  收藏  举报