@@ -18,7 +18,7 @@ msgid ""
1818msgstr ""
1919"Project-Id-Version : Python 3.9\n "
2020"Report-Msgid-Bugs-To : \n "
21- "POT-Creation-Date : 2021-02-03 05:20 +0000\n "
21+ "POT-Creation-Date : 2021-03-14 05:42 +0000\n "
2222"PO-Revision-Date : 2017-02-16 17:44+0000\n "
2323"
Last-Translator :
Freesand Leo <[email protected] >, 2021\n "
2424"Language-Team : Chinese (China) (https://www.transifex.com/python-doc/teams/5390/zh_CN/)\n "
@@ -927,8 +927,8 @@ msgid ""
927927msgstr "如果你曾好奇常规方法中的 *self* 或类方法中的 *cls* 是从什么地方来的,就是这里了!"
928928
929929#: ../../howto/descriptor.rst:1133
930- msgid "Static methods"
931- msgstr "静态方法 "
930+ msgid "Other kinds of methods"
931+ msgstr ""
932932
933933#: ../../howto/descriptor.rst:1135
934934msgid ""
@@ -991,7 +991,11 @@ msgstr "f(type(obj), \\*args)"
991991msgid "f(cls, \\ *args)"
992992msgstr "f(cls, \\ *args)"
993993
994- #: ../../howto/descriptor.rst:1156
994+ #: ../../howto/descriptor.rst:1158
995+ msgid "Static methods"
996+ msgstr "静态方法"
997+
998+ #: ../../howto/descriptor.rst:1160
995999msgid ""
9961000"Static methods return the underlying function without changes. Calling "
9971001"either ``c.f`` or ``C.f`` is the equivalent of a direct lookup into "
@@ -1002,13 +1006,13 @@ msgstr ""
10021006"静态方法返回底层函数,不做任何更改。调用 ``c.f`` 或 ``C.f`` 等效于通过 ``object.__getattribute__(c, "
10031007"\" f\" )`` 或 ``object.__getattribute__(C, \" f\" )`` 查找。这样该函数就可以从对象或类中进行相同的访问。"
10041008
1005- #: ../../howto/descriptor.rst:1162
1009+ #: ../../howto/descriptor.rst:1166
10061010msgid ""
10071011"Good candidates for static methods are methods that do not reference the "
10081012"``self`` variable."
10091013msgstr "适合作为静态方法的是那些不引用 ``self`` 变量的方法。"
10101014
1011- #: ../../howto/descriptor.rst:1165
1015+ #: ../../howto/descriptor.rst:1169
10121016msgid ""
10131017"For instance, a statistics package may include a container class for "
10141018"experimental data. The class provides normal methods for computing the "
@@ -1023,30 +1027,30 @@ msgstr ""
10231027" ``erf(x)`` 是在统计中的便捷转换,但并不直接依赖于特定的数据集。可以从对象或类中调用它: ``s.erf(1.5) --> .9332`` "
10241028"或 ``Sample.erf(1.5) --> .9332``。"
10251029
1026- #: ../../howto/descriptor.rst:1174
1030+ #: ../../howto/descriptor.rst:1178
10271031msgid ""
10281032"Since static methods return the underlying function with no changes, the "
10291033"example calls are unexciting:"
10301034msgstr "由于静态方法返回的底层函数没有任何变化,因此示例调用也是意料之中:"
10311035
1032- #: ../../howto/descriptor.rst:1191
1036+ #: ../../howto/descriptor.rst:1195
10331037msgid ""
10341038"Using the non-data descriptor protocol, a pure Python version of "
10351039":func:`staticmethod` would look like this:"
10361040msgstr "使用非数据描述器,纯 Python 版本的 :func:`staticmethod` 如下所示:"
10371041
1038- #: ../../howto/descriptor.rst:1207
1042+ #: ../../howto/descriptor.rst:1211
10391043msgid "Class methods"
10401044msgstr "类方法"
10411045
1042- #: ../../howto/descriptor.rst:1209
1046+ #: ../../howto/descriptor.rst:1213
10431047msgid ""
10441048"Unlike static methods, class methods prepend the class reference to the "
10451049"argument list before calling the function. This format is the same for "
10461050"whether the caller is an object or a class:"
10471051msgstr "与静态方法不同,类方法在调用函数之前将类引用放在参数列表的最前。无论调用方是对象还是类,此格式相同:"
10481052
1049- #: ../../howto/descriptor.rst:1227
1053+ #: ../../howto/descriptor.rst:1231
10501054msgid ""
10511055"This behavior is useful whenever the method only needs to have a class "
10521056"reference and does not rely on data stored in a specific instance. One use "
@@ -1057,17 +1061,17 @@ msgstr ""
10571061"当方法仅需要具有类引用并且确实依赖于存储在特定实例中的数据时,此行为就很有用。类方法的一种用途是创建备用类构造函数。例如,类方法 "
10581062":func:`dict.fromkeys` 从键列表创建一个新字典。纯 Python 的等价实现是:"
10591063
1060- #: ../../howto/descriptor.rst:1244
1064+ #: ../../howto/descriptor.rst:1248
10611065msgid "Now a new dictionary of unique keys can be constructed like this:"
10621066msgstr "现在可以这样构造一个新的唯一键字典:"
10631067
1064- #: ../../howto/descriptor.rst:1254
1068+ #: ../../howto/descriptor.rst:1258
10651069msgid ""
10661070"Using the non-data descriptor protocol, a pure Python version of "
10671071":func:`classmethod` would look like this:"
10681072msgstr "使用非数据描述器协议,纯 Python 版本的 :func:`classmethod` 如下:"
10691073
1070- #: ../../howto/descriptor.rst:1292
1074+ #: ../../howto/descriptor.rst:1296
10711075msgid ""
10721076"The code path for ``hasattr(obj, '__get__')`` was added in Python 3.9 and "
10731077"makes it possible for :func:`classmethod` to support chained decorators. For"
@@ -1076,30 +1080,30 @@ msgstr ""
10761080" ``hasattr(obj, '__get__')`` 的代码是在 Python 3.9 中加入的,这让 :func:`classmethod` "
10771081"可以支持链式装饰器。例如,一个类方法和属性可以链接在一起:"
10781082
1079- #: ../../howto/descriptor.rst:1311
1083+ #: ../../howto/descriptor.rst:1315
10801084msgid "Member objects and __slots__"
10811085msgstr "成员对象和 __slots__"
10821086
1083- #: ../../howto/descriptor.rst:1313
1087+ #: ../../howto/descriptor.rst:1317
10841088msgid ""
10851089"When a class defines ``__slots__``, it replaces instance dictionaries with a"
10861090" fixed-length array of slot values. From a user point of view that has "
10871091"several effects:"
10881092msgstr "当一个类定义了 ``__slots__``,它会用一个固定长度的 slot 值数组来替换实例字典。 从用户的视角看,效果是这样的:"
10891093
1090- #: ../../howto/descriptor.rst:1317
1094+ #: ../../howto/descriptor.rst:1321
10911095msgid ""
10921096"1. Provides immediate detection of bugs due to misspelled attribute "
10931097"assignments. Only attribute names specified in ``__slots__`` are allowed:"
10941098msgstr "1. 提供对由错误拼写的属性赋值导致的程序缺陷的即时检测。 只允许在 ``__slots__`` 中指定的属性名称:"
10951099
1096- #: ../../howto/descriptor.rst:1333
1100+ #: ../../howto/descriptor.rst:1337
10971101msgid ""
10981102"2. Helps create immutable objects where descriptors manage access to private"
10991103" attributes stored in ``__slots__``:"
11001104msgstr "2. 帮助创建由描述器来管理对保存在 ``__slots__`` 中的私有属性的访问的不可变对象:"
11011105
1102- #: ../../howto/descriptor.rst:1368
1106+ #: ../../howto/descriptor.rst:1372
11031107msgid ""
11041108"3. Saves memory. On a 64-bit Linux build, an instance with two attributes "
11051109"takes 48 bytes with ``__slots__`` and 152 bytes without. This `flyweight "
@@ -1110,13 +1114,13 @@ msgstr ""
11101114"152 个字节。 这种 `flyweight design pattern "
11111115"<https://en.wikipedia.org/wiki/Flyweight_pattern>`_ 通常仅在要创建大量实例时才能显示效果。"
11121116
1113- #: ../../howto/descriptor.rst:1373
1117+ #: ../../howto/descriptor.rst:1377
11141118msgid ""
11151119"4. Blocks tools like :func:`functools.cached_property` which require an "
11161120"instance dictionary to function correctly:"
11171121msgstr "4. 阻止 :func:`functools.cached_property` 之类需要实例字典才能正常运作的工具:"
11181122
1119- #: ../../howto/descriptor.rst:1395
1123+ #: ../../howto/descriptor.rst:1399
11201124msgid ""
11211125"It is not possible to create an exact drop-in pure Python version of "
11221126"``__slots__`` because it requires direct access to C structures and control "
@@ -1129,37 +1133,37 @@ msgstr ""
11291133"但是,我们可以构建一个非常相似的模拟版,其中作为 slot 的实际 C 结构体由一个私有的 ``_slotvalues`` 列表来模拟。 "
11301134"对该私有结构体的读写操作将由成员描述器来管理:"
11311135
1132- #: ../../howto/descriptor.rst:1438
1136+ #: ../../howto/descriptor.rst:1442
11331137msgid ""
11341138"The :meth:`type.__new__` method takes care of adding member objects to class"
11351139" variables:"
11361140msgstr ":meth:`type.__new__` 方法负责将成员对象添加到类变量:"
11371141
1138- #: ../../howto/descriptor.rst:1454
1142+ #: ../../howto/descriptor.rst:1458
11391143msgid ""
11401144"The :meth:`object.__new__` method takes care of creating instances that have"
11411145" slots instead of an instance dictionary. Here is a rough simulation in "
11421146"pure Python:"
11431147msgstr ":meth:`object.__new__` 方法负责创建具有 slot 而非实例字典的实例。 以下是一个纯 Python 的粗略模拟版:"
11441148
1145- #: ../../howto/descriptor.rst:1489
1149+ #: ../../howto/descriptor.rst:1493
11461150msgid ""
11471151"To use the simulation in a real class, just inherit from :class:`Object` and"
11481152" set the :term:`metaclass` to :class:`Type`:"
11491153msgstr ""
11501154"要在真实的类中使用这个模拟版,只需从 :class:`Object` 继承并将 :term:`metaclass` 设为 :class:`Type`:"
11511155
1152- #: ../../howto/descriptor.rst:1503
1156+ #: ../../howto/descriptor.rst:1507
11531157msgid ""
11541158"At this point, the metaclass has loaded member objects for *x* and *y*::"
11551159msgstr "这时,metaclass 已经为 *x* 和 *y* 加载了成员对象:"
11561160
1157- #: ../../howto/descriptor.rst:1524
1161+ #: ../../howto/descriptor.rst:1528
11581162msgid ""
11591163"When instances are created, they have a ``slot_values`` list where the "
11601164"attributes are stored:"
11611165msgstr "当实例被创建时,它们将拥有一个用于存放属性的 ``slot_values`` 列表:"
11621166
1163- #: ../../howto/descriptor.rst:1536
1167+ #: ../../howto/descriptor.rst:1540
11641168msgid "Misspelled or unassigned attributes will raise an exception:"
11651169msgstr "错误拼写或未赋值的属性将引发一个异常:"
0 commit comments