@@ -100,6 +100,10 @@ msgid ""
100100" there's lots of C code that expects a regular Python list and won't accept "
101101"a :class:`~collections.UserList` instance."
102102msgstr ""
103+ "很久以前,我写过一个网页,列出了 Python 设计中的一些缺陷。其中一个最显著的缺陷是无法对子类化用 C 实现的 Python "
104+ "类型。特别是,无法对子类化内置类型,因此你不能简单地对子类化列表,以便向其添加一个有用的方法。虽然 :mod:`!UserList` "
105+ "模块提供了一个支持所有列表方法的类并且可以进一步子类化,但有很多 C 代码期望的是一个普通的 Python 列表,不能接受 "
106+ ":class:`~collections.UserList` 实例。"
103107
104108#: ../../whatsnew/2.2.rst:61
105109msgid ""
@@ -127,6 +131,8 @@ msgid ""
127131"instead, making the resulting code simpler and faster. As a small side "
128132"benefit, attributes can now have docstrings, too."
129133msgstr ""
134+ "还可以通过使用一种称为 *属性* 的新机制,在访问或设置实例属性时自动调用方法。许多 :meth:`~object.__getattr__` "
135+ "的用法可以重写为使用属性,从而使代码更简单、更快速。作为一个小的额外好处,属性现在也可以有文档字符串。"
130136
131137#: ../../whatsnew/2.2.rst:76
132138msgid ""
@@ -197,6 +203,9 @@ msgid ""
197203"types, has also been added so if no built-in type is suitable, you can just "
198204"subclass :class:`object`::"
199205msgstr ""
206+ "那么如何定义一个新式类呢?你可以通过继承一个现有的新式类来实现。大多数 Python "
207+ "内置类型,如整数、列表、字典,甚至文件,现在都是新式类。此外,还添加了一个名为 :class:`object` "
208+ "的新式类,它是所有内置类型的基类,因此如果没有合适的内置类型,你可以直接继承 :class:`object` 类:"
200209
201210#: ../../whatsnew/2.2.rst:121
202211msgid ""
@@ -206,6 +215,9 @@ msgid ""
206215" :pep:`253` for the details --- but it's easier to just subclass "
207216":class:`object`.)"
208217msgstr ""
218+ "这意味着在 Python 2.2 中,不带任何基类的 :keyword:`class` 声明总是经典类。(实际上,你也可以通过设置一个名为 "
219+ ":attr:`!__metaclass__` 的模块级变量来改变这一点——详见 :pep:`253` ——但更简单的方法是直接继承 "
220+ ":class:`object`。)"
209221
210222#: ../../whatsnew/2.2.rst:126
211223msgid ""
@@ -214,13 +226,18 @@ msgid ""
214226":func:`int`, :func:`float`, and :func:`str`. In 2.2, they aren't functions "
215227"any more, but type objects that behave as factories when called. ::"
216228msgstr ""
229+ "内置类型的类型对象在 Python 2.2 中作为内置对象提供,使用了一种巧妙的技巧命名。Python 一直有名为 "
230+ ":func:`int`、:func:`float` 和 :func:`str` 的内置函数。在 Python 2.2 "
231+ "中,它们不再是函数,而是作为被调用时表现为工厂的类型对象。"
217232
218233#: ../../whatsnew/2.2.rst:136
219234msgid ""
220235"To make the set of types complete, new type objects such as :func:`dict` and"
221236" :func:`!file` have been added. Here's a more interesting example, adding a"
222237" :meth:`!lock` method to file objects::"
223238msgstr ""
239+ "为了使类型集合完整,Python 2.2 中还添加了新的类型对象,例如 :func:`dict` 和 "
240+ ":func:`!file`。以下是一个更有趣的例子,向文件对象添加一个 :meth:`!lock` 方法:"
224241
225242#: ../../whatsnew/2.2.rst:146
226243msgid ""
0 commit comments