88# Yinuo Huang <[email protected] >, 201899# Fei Yin <[email protected] >, 20181010# Junkai Shao <[email protected] >, 201811- # Freesand Leo <[email protected] >, 201812111312# Siyuan Xu <[email protected] >, 20191413# ppcfish <[email protected] >, 201914+ # WH-2099 <[email protected] >, 202015+ # Freesand Leo <[email protected] >, 20201516#
1617#, fuzzy
1718msgid ""
@@ -20,7 +21,7 @@ msgstr ""
2021"Report-Msgid-Bugs-To : \n "
2122"POT-Creation-Date : 2020-02-09 12:40+0000\n "
2223"PO-Revision-Date : 2017-02-16 17:44+0000\n "
23- "Last-Translator : ppcfish <ppcfish@gmail .com>, 2019 \n "
24+ "Last-Translator : Freesand Leo <yuqinju@163 .com>, 2020 \n "
2425"Language-Team : Chinese (China) (https://www.transifex.com/python-doc/teams/5390/zh_CN/)\n "
2526"MIME-Version : 1.0\n "
2627"Content-Type : text/plain; charset=UTF-8\n "
@@ -30,7 +31,7 @@ msgstr ""
3031
3132#: ../../howto/descriptor.rst:3
3233msgid "Descriptor HowTo Guide"
33- msgstr "实现描述器 "
34+ msgstr "描述器使用指南 "
3435
3536#: ../../howto/descriptor.rst:0
3637msgid "Author"
@@ -64,6 +65,8 @@ msgid ""
6465"methods. Shows how each works by giving a pure Python equivalent and a "
6566"sample application."
6667msgstr ""
68+ "定义描述器,总结描述器协议,展示描述器被如何使用。测试一个自定义的描述器和若干 Python "
69+ "内置的描述器,包括函数、属性、静态方法和类方法。通过给出一个纯 Python 的等价实现和例程,展示每个描述器如何工作。"
6770
6871#: ../../howto/descriptor.rst:18
6972msgid ""
@@ -113,6 +116,8 @@ msgid ""
113116"underlying C-code and offer a flexible set of new tools for everyday Python "
114117"programs."
115118msgstr ""
119+ "描述器是一个强大而通用的协议。 它们是特征属性、方法静态方法、类方法和 :func:`super()` 背后的实现机制。 它们在 Python "
120+ "内部被广泛使用来实现自 2.2 版中引入的新式类。 描述器简化了底层的 C 代码并为 Python 的日常程序提供了一组灵活的新工具。"
116121
117122#: ../../howto/descriptor.rst:49
118123msgid "Descriptor Protocol"
@@ -135,7 +140,7 @@ msgid ""
135140"That is all there is to it. Define any of these methods and an object is "
136141"considered a descriptor and can override default behavior upon being looked "
137142"up as an attribute."
138- msgstr ""
143+ msgstr "以上就是全部。定义这些方法中的任何一个的对象被视为描述器,并在被作为属性时覆盖其默认行为。 "
139144
140145#: ../../howto/descriptor.rst:61
141146msgid ""
@@ -144,6 +149,8 @@ msgid ""
144149" non-data descriptors (they are typically used for methods but other uses "
145150"are possible)."
146151msgstr ""
152+ "如果一个对象定义了 :meth:`__set__` 或 :meth:`__delete__`,则它会被视为数据描述器。 仅定义了 "
153+ ":meth:`__get__` 的描述器称为非数据描述器(它们通常被用于方法,但也可以有其他用途)。"
147154
148155#: ../../howto/descriptor.rst:66
149156msgid ""
@@ -153,6 +160,7 @@ msgid ""
153160"takes precedence. If an instance's dictionary has an entry with the same "
154161"name as a non-data descriptor, the dictionary entry takes precedence."
155162msgstr ""
163+ "数据和非数据描述器的不同之处在于,如何计算实例字典中条目的替代值。如果实例的字典具有与数据描述器同名的条目,则数据描述器优先。如果实例的字典具有与非数据描述器同名的条目,则该字典条目优先。"
156164
157165#: ../../howto/descriptor.rst:72
158166msgid ""
@@ -161,16 +169,18 @@ msgid ""
161169"when called. Defining the :meth:`__set__` method with an exception raising "
162170"placeholder is enough to make it a data descriptor."
163171msgstr ""
172+ "为了使只读数据描述符,同时定义 :meth:`__get__` 和 :meth:`__set__` ,并在 :meth:`__set__` 中引发 "
173+ ":exc:`AttributeError` 。用引发异常的占位符定义 :meth:`__set__` 方法能够使其成为数据描述符。"
164174
165175#: ../../howto/descriptor.rst:79
166176msgid "Invoking Descriptors"
167- msgstr "发起调用描述符 "
177+ msgstr "发起调用描述器 "
168178
169179#: ../../howto/descriptor.rst:81
170180msgid ""
171181"A descriptor can be called directly by its method name. For example, "
172182"``d.__get__(obj)``."
173- msgstr ""
183+ msgstr "描述器可以通过其方法名称直接调用。例如, ``d.__get__(obj)`` 。 "
174184
175185#: ../../howto/descriptor.rst:84
176186msgid ""
@@ -180,11 +190,13 @@ msgid ""
180190"then ``d.__get__(obj)`` is invoked according to the precedence rules listed "
181191"below."
182192msgstr ""
193+ "或者,更常见的是在属性访问时自动调用描述符。例如,在中 ``obj.d`` 会在 ``d`` 的字典中查找 ``obj`` 。如果 ``d`` "
194+ "定义了方法 :meth:`__get__` ,则 ``d.__get__(obj)`` 根据下面列出的优先级规则进行调用。"
183195
184196#: ../../howto/descriptor.rst:89
185197msgid ""
186198"The details of invocation depend on whether ``obj`` is an object or a class."
187- msgstr ""
199+ msgstr "调用的细节取决于 ``obj`` 是对象还是类。 "
188200
189201#: ../../howto/descriptor.rst:91
190202msgid ""
@@ -196,40 +208,49 @@ msgid ""
196208" The full C implementation can be found in "
197209":c:func:`PyObject_GenericGetAttr()` in :source:`Objects/object.c`."
198210msgstr ""
211+ "对于对象来说,机制是 :meth:`object.__getattribute__` 中将 ``b.x`` 转换为 "
212+ "``type(b).__dict__['x'].__get__(b, type(b))`` 。 "
213+ "这个实现通过一个优先级链完成,该优先级链赋予数据描述器优先于实例变量的优先级,实例变量优先于非数据描述器的优先级,并如果 "
214+ ":meth:`__getattr__` 方法存在,为其分配最低的优先级。 完整的C实现可在 :source:`Objects/object.c` 中的 "
215+ ":c:func:`PyObject_GenericGetAttr()` 找到。"
199216
200217#: ../../howto/descriptor.rst:99
201218msgid ""
202219"For classes, the machinery is in :meth:`type.__getattribute__` which "
203220"transforms ``B.x`` into ``B.__dict__['x'].__get__(None, B)``. In pure "
204221"Python, it looks like::"
205222msgstr ""
223+ "对于类来说,机制是 :meth:`type.__getattribute__` 中将 ``B.x`` 转换为 "
224+ "``B.__dict__['x'].__get__(None, B)`` 。在纯Python中,它就像::"
206225
207226#: ../../howto/descriptor.rst:110
208227msgid "The important points to remember are:"
209- msgstr ""
228+ msgstr "要记住的重要点是: "
210229
211230#: ../../howto/descriptor.rst:112
212231msgid "descriptors are invoked by the :meth:`__getattribute__` method"
213- msgstr ""
232+ msgstr "描述器由 :meth:`__getattribute__` 方法调用 "
214233
215234#: ../../howto/descriptor.rst:113
216235msgid ""
217236"overriding :meth:`__getattribute__` prevents automatic descriptor calls"
218- msgstr ""
237+ msgstr "重写 :meth:`__getattribute__` 会阻止描述器的自动调用 "
219238
220239#: ../../howto/descriptor.rst:114
221240msgid ""
222241":meth:`object.__getattribute__` and :meth:`type.__getattribute__` make "
223242"different calls to :meth:`__get__`."
224243msgstr ""
244+ ":meth:`object.__getattribute__` 和 :meth:`type.__getattribute__` 会用不同的方式调用 "
245+ ":meth:`__get__`."
225246
226247#: ../../howto/descriptor.rst:116
227248msgid "data descriptors always override instance dictionaries."
228- msgstr ""
249+ msgstr "数据描述器始终会覆盖实例字典。 "
229250
230251#: ../../howto/descriptor.rst:117
231252msgid "non-data descriptors may be overridden by instance dictionaries."
232- msgstr ""
253+ msgstr "非数据描述器会被实例字典覆盖。 "
233254
234255#: ../../howto/descriptor.rst:119
235256msgid ""
@@ -354,7 +375,7 @@ msgstr ""
354375
355376#: ../../howto/descriptor.rst:326
356377msgid "Static Methods and Class Methods"
357- msgstr ""
378+ msgstr "静态方法和类方法 "
358379
359380#: ../../howto/descriptor.rst:328
360381msgid ""
@@ -446,13 +467,13 @@ msgstr ""
446467msgid ""
447468"Since staticmethods return the underlying function with no changes, the "
448469"example calls are unexciting::"
449- msgstr ""
470+ msgstr "由于静态方法直接返回了底层的函数,因此示例调用是平淡的: "
450471
451472#: ../../howto/descriptor.rst:380
452473msgid ""
453474"Using the non-data descriptor protocol, a pure Python version of "
454475":func:`staticmethod` would look like this::"
455- msgstr ""
476+ msgstr "使用非数据描述器,纯Python的版本 :func:`staticmethod` 如下所示: "
456477
457478#: ../../howto/descriptor.rst:392
458479msgid ""
0 commit comments