Search This Blog

Labels

Friday, December 17, 2010

《扩展和嵌入Python解释器(译稿)》2.0 Defining New Types

As mentioned in the last chapter, Python allows the writer of an extension module to define new types that can be manipulated from Python code, much like strings and lists in core Python.

正如上一章提到的,Python 允许扩展模块的作者定义可在Python代码中操作的新类型,就像内核中的string和list一样。

This is not hard; the code for all extension types follows a pattern, but there are some details that you need to understand before you can get started.

这并不困难;所有扩展类型的代码都遵循同一个模式,但在你开始之前还有一些细节需要了解。

Note:The way new types are defined changed dramatically (and for the better) in Python 2.2. This document documents how to define new types for Python 2.2 and later. If you need to support older versions of Python, you will need to refer to older versions of this documentation.

注意:定义新类型的方式在Python 2.2中有了显著的变化(也是为了更好)。本文档记录了如何为 Python 2.2 和更新的版本定义新类型。如果你需要老版本Python的支持,你要去查阅本文档的老版本

No comments:

Post a Comment