预计阅读本页时间:-
喜欢这本书吗?请把本站加入广告屏蔽插件白名单
无弹窗/漂浮窗等广告形式,不影响阅读
Extending Built-in Types
Besides implementing new kinds of objects, classes are sometimes used to extend the functionality of Python’s built-in types to support more exotic data structures. For instance, to add queue insert and delete methods to lists, you can code classes that wrap (embed) a list object and export insert and delete methods that process the list specially, like the delegation technique we studied in Chapter 30. As of Python 2.2, you can also use inheritance to specialize built-in types. The next two sections show both techniques in action.