@@ -401,7 +401,7 @@ msgstr "静态方法和类方法"
401401msgid ""
402402"Non-data descriptors provide a simple mechanism for variations on the usual "
403403"patterns of binding functions into methods."
404- msgstr ""
404+ msgstr "非数据描述器为把函数绑定为方法的通常模式提供了一种简单的机制。 "
405405
406406#: ../../howto/descriptor.rst:331
407407msgid ""
@@ -410,22 +410,24 @@ msgid ""
410410"transforms an ``obj.f(*args)`` call into ``f(obj, *args)``. Calling "
411411"``klass.f(*args)`` becomes ``f(*args)``."
412412msgstr ""
413+ "概括地说,函数具有 :meth:`__get__` 方法,以便在作为属性访问时可以将其转换为方法。非数据描述符将 ``obj.f(*args)`` "
414+ "的调用转换为 ``f(obj, *args)`` 。调用 `klass.f(*args)`` 因而变成 ``f(*args)`` 。"
413415
414416#: ../../howto/descriptor.rst:336
415417msgid "This chart summarizes the binding and its two most useful variants:"
416- msgstr ""
418+ msgstr "下表总结了绑定及其两个最有用的变体: "
417419
418420#: ../../howto/descriptor.rst:339
419421msgid "Transformation"
420- msgstr ""
422+ msgstr "转换形式 "
421423
422424#: ../../howto/descriptor.rst:339
423425msgid "Called from an Object"
424- msgstr ""
426+ msgstr "通过对象调用 "
425427
426428#: ../../howto/descriptor.rst:339
427429msgid "Called from a Class"
428- msgstr ""
430+ msgstr "通过类调用 "
429431
430432#: ../../howto/descriptor.rst:342
431433msgid "function"
@@ -464,12 +466,14 @@ msgid ""
464466"\" f\" )``. As a result, the function becomes identically accessible from "
465467"either an object or a class."
466468msgstr ""
469+ "静态方法返回底层函数,不做任何更改。调用 ``c.f`` 或 ``C.f`` 等效于通过 ``object.__getattribute__(c, "
470+ "\" f\" )`` 或 ``object.__getattribute__(C, \" f\" )`` 查找。结果,该函数变得可以从对象或类中进行相同的访问。"
467471
468472#: ../../howto/descriptor.rst:355
469473msgid ""
470474"Good candidates for static methods are methods that do not reference the "
471475"``self`` variable."
472- msgstr ""
476+ msgstr "适合于作为静态方法的是那些不引用 ``self`` 变量的方法。 "
473477
474478#: ../../howto/descriptor.rst:358
475479msgid ""
@@ -482,25 +486,28 @@ msgid ""
482486" particular dataset. It can be called either from an object or the class: "
483487"``s.erf(1.5) --> .9332`` or ``Sample.erf(1.5) --> .9332``."
484488msgstr ""
489+ "例如,一个统计用的包可能包含一个实验数据的容器类。该容器类提供了用于计算数据的平均值,均值,中位数和其他描述性统计信息的常规方法。但是,可能有在概念上相关但不依赖于数据的函数。例如,"
490+ " ``erf(x)`` 是在统计中的便捷转换,但并不直接依赖于特定的数据集。可以从对象或类中调用它: ``s.erf(1.5) --> .9332`` "
491+ "或 ``Sample.erf(1.5) --> .9332``。"
485492
486493#: ../../howto/descriptor.rst:367
487494msgid ""
488495"Since staticmethods return the underlying function with no changes, the "
489496"example calls are unexciting::"
490- msgstr "由于静态方法直接返回了底层的函数,因此示例调用是平淡的 :"
497+ msgstr "由于静态方法直接返回了底层的函数,因此示例调用是相同的 :"
491498
492499#: ../../howto/descriptor.rst:380
493500msgid ""
494501"Using the non-data descriptor protocol, a pure Python version of "
495502":func:`staticmethod` would look like this::"
496- msgstr "使用非数据描述器,纯Python的版本 :func:`staticmethod` 如下所示:"
503+ msgstr "使用非数据描述器,纯 Python 版本的 :func:`staticmethod` 如下所示:"
497504
498505#: ../../howto/descriptor.rst:392
499506msgid ""
500507"Unlike static methods, class methods prepend the class reference to the "
501508"argument list before calling the function. This format is the same for "
502509"whether the caller is an object or a class::"
503- msgstr ""
510+ msgstr "与静态方法不同,类方法在调用函数之前将类引用放在参数列表的最前。无论调用方是对象还是类,此格式相同: "
504511
505512#: ../../howto/descriptor.rst:407
506513msgid ""
@@ -510,13 +517,15 @@ msgid ""
510517"classmethod :func:`dict.fromkeys` creates a new dictionary from a list of "
511518"keys. The pure Python equivalent is::"
512519msgstr ""
520+ "当函数仅需要使用类引用并且不关心任何底层数据时,此行为就很有用。类方法的一种用途是创建替代的类构造函数。在 Python 2.3 中,类方法 "
521+ ":func:`dict.fromkeys` 从键列表创建一个新的字典。纯 Python 等价实现是::"
513522
514523#: ../../howto/descriptor.rst:423
515524msgid "Now a new dictionary of unique keys can be constructed like this::"
516- msgstr ""
525+ msgstr "现在可以这样构造一个新的唯一键字典: "
517526
518527#: ../../howto/descriptor.rst:428
519528msgid ""
520529"Using the non-data descriptor protocol, a pure Python version of "
521530":func:`classmethod` would look like this::"
522- msgstr ""
531+ msgstr "使用非数据描述符协议,纯 Python 版本的 :func:`classmethod` 如下: "
0 commit comments