Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 988bfa0

Browse files
[po] auto sync
1 parent 4bcd3d3 commit 988bfa0

1 file changed

Lines changed: 30 additions & 16 deletions

File tree

howto/descriptor.po

Lines changed: 30 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -169,8 +169,8 @@ msgid ""
169169
"when called. Defining the :meth:`__set__` method with an exception raising "
170170
"placeholder is enough to make it a data descriptor."
171171
msgstr ""
172-
"为了使只读数据描述符,同时定义 :meth:`__get__` 和 :meth:`__set__` ,并在 :meth:`__set__` 中引发 "
173-
":exc:`AttributeError` 。用引发异常的占位符定义 :meth:`__set__` 方法能够使其成为数据描述符。"
172+
"为了使数据描述器成为只读的,应该同时定义 :meth:`__get__` 和 :meth:`__set__` ,并在 :meth:`__set__` "
173+
"中引发 :exc:`AttributeError` 。用引发异常的占位符定义 :meth:`__set__` 方法使其成为数据描述器。"
174174

175175
#: ../../howto/descriptor.rst:79
176176
msgid "Invoking Descriptors"
@@ -190,7 +190,7 @@ msgid ""
190190
"then ``d.__get__(obj)`` is invoked according to the precedence rules listed "
191191
"below."
192192
msgstr ""
193-
"或者,更常见的是在属性访问时自动调用描述符。例如,在中 ``obj.d`` 会在 ``d`` 的字典中查找 ``obj`` 。如果 ``d`` "
193+
"或者,更常见的是在属性访问时自动调用描述器。例如,在中 ``obj.d`` 会在 ``d`` 的字典中查找 ``obj`` 。如果 ``d`` "
194194
"定义了方法 :meth:`__get__` ,则 ``d.__get__(obj)`` 根据下面列出的优先级规则进行调用。"
195195

196196
#: ../../howto/descriptor.rst:89
@@ -209,8 +209,8 @@ msgid ""
209209
":c:func:`PyObject_GenericGetAttr()` in :source:`Objects/object.c`."
210210
msgstr ""
211211
"对于对象来说,机制是 :meth:`object.__getattribute__` 中将 ``b.x`` 转换为 "
212-
"``type(b).__dict__['x'].__get__(b, type(b))`` "
213-
"这个实现通过一个优先级链完成,该优先级链赋予数据描述器优先于实例变量的优先级,实例变量优先于非数据描述器的优先级,并如果 "
212+
"``type(b).__dict__['x'].__get__(b, type(b))`` "
213+
"这个实现通过一个优先级链完成,该优先级链赋予数据描述器优先于实例变量的优先级,实例变量优先于非数据描述器的优先级,并如果 "
214214
":meth:`__getattr__` 方法存在,为其分配最低的优先级。 完整的C实现可在 :source:`Objects/object.c` 中的 "
215215
":c:func:`PyObject_GenericGetAttr()` 找到。"
216216

@@ -221,7 +221,7 @@ msgid ""
221221
"Python, it looks like::"
222222
msgstr ""
223223
"对于类来说,机制是 :meth:`type.__getattribute__` 中将 ``B.x`` 转换为 "
224-
"``B.__dict__['x'].__get__(None, B)`` 。在纯Python中,它就像::"
224+
"``B.__dict__['x'].__get__(None, B)`` 。在纯 Python中 ,它就像::"
225225

226226
#: ../../howto/descriptor.rst:110
227227
msgid "The important points to remember are:"
@@ -264,7 +264,7 @@ msgid ""
264264
msgstr ""
265265
" ``super()`` 返回的对象还有一个自定义的 :meth:`__getattribute__` 方法来调用描述器。属性查找 ``super(B,"
266266
" obj).m`` 在紧随 ``B`` 后的基类 ``A`` 中搜索 ``obj.__class__.__mro__`` ,然后返回 "
267-
"``A.__dict__['m'].__get__(obj, B)`` 。如果其不是描述符,则直接返回 ``m`` 。如果不在字典中, ``m`` "
267+
"``A.__dict__['m'].__get__(obj, B)`` 。如果其不是描述器,则直接返回 ``m`` 。如果不在字典中, ``m`` "
268268
"才回退使用 :meth:`object.__getattribute__` 进行搜索。 "
269269

270270
#: ../../howto/descriptor.rst:126
@@ -274,7 +274,7 @@ msgid ""
274274
"in `Guido's Tutorial`_."
275275
msgstr ""
276276
"这个实现的具体细节在 :source:`Objects/typeobject.c`. 的 :c:func:`super_getattro()` "
277-
"中,并且你还可以在 `Guido's Tutorial`_ 中找到等价的纯Python实现。"
277+
"中,并且你还可以在 `Guido's Tutorial`_ 中找到等价的纯 Python 实现。"
278278

279279
#: ../../howto/descriptor.rst:132
280280
msgid ""
@@ -285,10 +285,13 @@ msgid ""
285285
"functionality. Likewise, classes can turn-off descriptor invocation by "
286286
"overriding :meth:`__getattribute__()`."
287287
msgstr ""
288+
"以上展示的关于描述器机制的细节嵌入在 :class:`object` , :class:`type` , 和 :func:`super` 中的 "
289+
":meth:`__getattribute__()` 。当类派生自类 :class:`object` "
290+
"或有提供类似功能的元类时,它们将继承此机制。同样,类可以通过重写 :meth:`__getattribute__()` 阻止描述器调用。"
288291

289292
#: ../../howto/descriptor.rst:141
290293
msgid "Descriptor Example"
291-
msgstr "描述符示例"
294+
msgstr "描述器示例"
292295

293296
#: ../../howto/descriptor.rst:143
294297
msgid ""
@@ -297,6 +300,8 @@ msgid ""
297300
" alternate approach that could do this for every attribute. However, this "
298301
"descriptor is useful for monitoring just a few chosen attributes::"
299302
msgstr ""
303+
"以下代码创建一个类,其对象是数据描述器,该描述器为每个 get 或 set 打印一条消息。 覆盖 :meth:`__getattribute__` "
304+
"是可以对每个属性执行此操作的替代方法。但是,此描述器对于跟踪仅几个选定的属性很有用::"
300305

301306
#: ../../howto/descriptor.rst:181
302307
msgid ""
@@ -305,35 +310,36 @@ msgid ""
305310
"Properties, bound methods, static methods, and class methods are all based "
306311
"on the descriptor protocol."
307312
msgstr ""
313+
"这个协议很简单,并提供了令人兴奋的可能性。有几种用例非常普遍,以至于它们被打包到单独的函数调用中。属性、绑定方法、静态方法和类方法均基于描述器协议。"
308314

309315
#: ../../howto/descriptor.rst:188
310316
msgid "Properties"
311-
msgstr ""
317+
msgstr "属性"
312318

313319
#: ../../howto/descriptor.rst:190
314320
msgid ""
315321
"Calling :func:`property` is a succinct way of building a data descriptor "
316322
"that triggers function calls upon access to an attribute. Its signature "
317323
"is::"
318-
msgstr ""
324+
msgstr "调用 :func:`property` 是构建数据描述器的简洁方式,该数据描述器在访问属性时触发函数调用。它的签名是::"
319325

320326
#: ../../howto/descriptor.rst:195
321327
msgid ""
322328
"The documentation shows a typical use to define a managed attribute ``x``::"
323-
msgstr ""
329+
msgstr "该文档显示了定义托管属性 ``x`` 的典型用法::"
324330

325331
#: ../../howto/descriptor.rst:203
326332
msgid ""
327333
"To see how :func:`property` is implemented in terms of the descriptor "
328334
"protocol, here is a pure Python equivalent::"
329-
msgstr ""
335+
msgstr "要了解 :func:`property` 如何根据描述器协议实现,这里是一个纯 Python 的等价实现如何"
330336

331337
#: ../../howto/descriptor.rst:243
332338
msgid ""
333339
"The :func:`property` builtin helps whenever a user interface has granted "
334340
"attribute access and then subsequent changes require the intervention of a "
335341
"method."
336-
msgstr ""
342+
msgstr "这个内置的 :func:`property` 每当用户访问属性时生效,随后的变化需要一个方法的参与。"
337343

338344
#: ../../howto/descriptor.rst:247
339345
msgid ""
@@ -344,6 +350,9 @@ msgid ""
344350
"solution is to wrap access to the value attribute in a property data "
345351
"descriptor::"
346352
msgstr ""
353+
"例如,一个电子表格类可以通过 ``Cell('b10').value`` "
354+
"授予对单元格值的访问权限。对程序的后续改进要求每次访问都要重新计算单元格;但是,程序员不希望影响直接访问该属性的现有客户端代码。解决方案是将对 "
355+
"value 属性的访问包装在属性数据描述器中::"
347356

348357
#: ../../howto/descriptor.rst:263
349358
msgid "Functions and Methods"
@@ -353,7 +362,7 @@ msgstr "函数和方法"
353362
msgid ""
354363
"Python's object oriented features are built upon a function based "
355364
"environment. Using non-data descriptors, the two are merged seamlessly."
356-
msgstr ""
365+
msgstr "Python 的面向对象功能是在基于函数的环境构建的。通过使用非数据描述器,这两方面完成了无缝融合。"
357366

358367
#: ../../howto/descriptor.rst:268
359368
msgid ""
@@ -364,6 +373,9 @@ msgid ""
364373
"convention, the instance reference is called *self* but may be called *this*"
365374
" or any other variable name."
366375
msgstr ""
376+
"类字典将方法存储为函数。在类定义中,方法是用 :keyword:`def` 或 :keyword:`lambda` "
377+
"这两个创建函数的常用工具编写的。方法与常规函数的不同之处仅在于第一个参数是为对象实例保留的。按照 Python 约定,实例引用称为 *self* "
378+
",但也可以称为 *this* 或任何其他变量名称。"
367379

368380
#: ../../howto/descriptor.rst:275
369381
msgid ""
@@ -372,12 +384,14 @@ msgid ""
372384
"non-data descriptors which return bound methods when they are invoked from "
373385
"an object. In pure Python, it works like this::"
374386
msgstr ""
387+
"为了支持方法调用,函数包含 :meth:`__get__` "
388+
"方法用于在访问属性时将其绑定成方法。这意味着所有函数都是非数据描述器,当从对象调用它们时,它们返回绑定方法。在纯 Python 中,它的工作方式如下::"
375389

376390
#: ../../howto/descriptor.rst:288
377391
msgid ""
378392
"Running the interpreter shows how the function descriptor works in "
379393
"practice::"
380-
msgstr ""
394+
msgstr "运行解释器显示了函数描述器在实践中的工作方式:"
381395

382396
#: ../../howto/descriptor.rst:326
383397
msgid "Static Methods and Class Methods"

0 commit comments

Comments
 (0)