@@ -11,7 +11,7 @@ msgid ""
1111msgstr ""
1212"Project-Id-Version : Python 3.12\n "
1313"Report-Msgid-Bugs-To : \n "
14- "POT-Creation-Date : 2024-05-11 19:07 +0000\n "
14+ "POT-Creation-Date : 2024-05-17 14:44 +0000\n "
1515"PO-Revision-Date : 2024-05-11 00:33+0000\n "
1616"
Last-Translator :
Rafael Fontenelle <[email protected] >, 2024\n "
1717"Language-Team : Chinese (China) (https://app.transifex.com/python-doc/teams/5390/zh_CN/)\n "
@@ -833,16 +833,15 @@ msgstr ""
833833msgid ""
834834"There is a tiny performance penalty when using ``frozen=True``: "
835835":meth:`~object.__init__` cannot use simple assignment to initialize fields, "
836- "and must use :meth:`!__setattr__`."
836+ "and must use :meth:`!object.__setattr__`. .. Make sure to not remove "
837+ "\" object\" from \" object.__setattr__\" in the above markup"
837838msgstr ""
838- "在使用 ``frozen=True`` 时会有微小的性能损失: :meth:`~object.__init__` "
839- "不能使用简单赋值来初始化字段,而必须使用 :meth:`!__setattr__`。"
840839
841- #: ../../library/dataclasses.rst:621
840+ #: ../../library/dataclasses.rst:622
842841msgid "Inheritance"
843842msgstr "继承"
844843
845- #: ../../library/dataclasses.rst:623
844+ #: ../../library/dataclasses.rst:624
846845msgid ""
847846"When the dataclass is being created by the :func:`@dataclass <dataclass>` "
848847"decorator, it looks through all of the class's base classes in reverse MRO "
@@ -857,7 +856,7 @@ msgstr ""
857856":class:`object` 开始)查看它的所有基类,并将找到的每个数据类的字段添加到一个有序映射中。 所有生成的方法都将使用这个有序映射。 "
858857"字段会遵守它们被插入的顺序,因此派生类会重写基类。 一个例子::"
859858
860- #: ../../library/dataclasses.rst:643
859+ #: ../../library/dataclasses.rst:644
861860msgid ""
862861"The final list of fields is, in order, :attr:`!x`, :attr:`!y`, :attr:`!z`. "
863862"The final type of :attr:`!x` is :class:`int`, as specified in class "
@@ -866,17 +865,17 @@ msgstr ""
866865"最终的字段列表依次是 :attr:`!x`, :attr:`!y`, :attr:`!z`。 最终的 :attr:`!x` 类型是 "
867866":class:`int`,正如类 :class:`!C` 中所指定的。"
868867
869- #: ../../library/dataclasses.rst:646
868+ #: ../../library/dataclasses.rst:647
870869msgid ""
871870"The generated :meth:`~object.__init__` method for :class:`!C` will look "
872871"like::"
873872msgstr "为 :class:`!C` 生成的 :meth:`~object.__init__` 方法看起来像是这样::"
874873
875- #: ../../library/dataclasses.rst:651
874+ #: ../../library/dataclasses.rst:652
876875msgid "Re-ordering of keyword-only parameters in :meth:`!__init__`"
877876msgstr ":meth:`!__init__` 中仅限关键字形参的重新排序"
878877
879- #: ../../library/dataclasses.rst:653
878+ #: ../../library/dataclasses.rst:654
880879msgid ""
881880"After the parameters needed for :meth:`~object.__init__` are computed, any "
882881"keyword-only parameters are moved to come after all regular (non-keyword-"
@@ -886,7 +885,7 @@ msgstr ""
886885"在计算出 :meth:`~object.__init__` 所需要的形参之后,任何仅限关键字形参会被移至所有常规(非仅限关键字)形参的后面。 这是 "
887886"Python 中实现仅限关键字形参所要求的:它们必须位于非仅限关键字形参之后。"
888887
889- #: ../../library/dataclasses.rst:659
888+ #: ../../library/dataclasses.rst:660
890889msgid ""
891890"In this example, :attr:`!Base.y`, :attr:`!Base.w`, and :attr:`!D.t` are "
892891"keyword-only fields, and :attr:`!Base.x` and :attr:`!D.z` are regular "
@@ -895,29 +894,29 @@ msgstr ""
895894"在这个例子中,:attr:`!Base.y`, :attr:`!Base.w` 和 :attr:`!D.t` 是仅限关键字字段,而 "
896895":attr:`!Base.x` 和 :attr:`!D.z` 是常规字段::"
897896
898- #: ../../library/dataclasses.rst:674
897+ #: ../../library/dataclasses.rst:675
899898msgid ""
900899"The generated :meth:`!__init__` method for :class:`!D` will look like::"
901900msgstr "为 :class:`!D` 生成的 :meth:`!__init__` 方法看起来像是这样::"
902901
903- #: ../../library/dataclasses.rst:678
902+ #: ../../library/dataclasses.rst:679
904903msgid ""
905904"Note that the parameters have been re-ordered from how they appear in the "
906905"list of fields: parameters derived from regular fields are followed by "
907906"parameters derived from keyword-only fields."
908907msgstr "请注意形参原来在字段列表中出现的位置已被重新排序:前面是来自常规字段的形参而后面是来自仅限关键字字段的形参。"
909908
910- #: ../../library/dataclasses.rst:682
909+ #: ../../library/dataclasses.rst:683
911910msgid ""
912911"The relative ordering of keyword-only parameters is maintained in the re-"
913912"ordered :meth:`!__init__` parameter list."
914913msgstr "仅限关键字形参的相对顺序会在重新排序的 :meth:`!__init__` 列表中保持不变。"
915914
916- #: ../../library/dataclasses.rst:687
915+ #: ../../library/dataclasses.rst:688
917916msgid "Default factory functions"
918917msgstr "默认工厂函数"
919918
920- #: ../../library/dataclasses.rst:689
919+ #: ../../library/dataclasses.rst:690
921920msgid ""
922921"If a :func:`field` specifies a *default_factory*, it is called with zero "
923922"arguments when a default value for the field is needed. For example, to "
@@ -926,7 +925,7 @@ msgstr ""
926925"如果一个 :func:`field` 指定了 *default_factory*,它将在该字段需要默认值时不带参数地被调用。 "
927926"例如,要创建一个列表的新实例,则使用::"
928927
929- #: ../../library/dataclasses.rst:695
928+ #: ../../library/dataclasses.rst:696
930929msgid ""
931930"If a field is excluded from :meth:`~object.__init__` (using ``init=False``) "
932931"and the field also specifies *default_factory*, then the default factory "
@@ -938,31 +937,31 @@ msgstr ""
938937"*default_factory*,则默认的工厂函数将总是会从生成的 :meth:`!__init__` 函数中被调用。 "
939938"发生这种情况是因为没有其他方式能为字段提供初始值。"
940939
941- #: ../../library/dataclasses.rst:702
940+ #: ../../library/dataclasses.rst:703
942941msgid "Mutable default values"
943942msgstr "可变的默认值"
944943
945- #: ../../library/dataclasses.rst:704
944+ #: ../../library/dataclasses.rst:705
946945msgid ""
947946"Python stores default member variable values in class attributes. Consider "
948947"this example, not using dataclasses::"
949948msgstr "Python 在类属性中存储默认成员变量值。思考这个例子,不使用数据类::"
950949
951- #: ../../library/dataclasses.rst:719
950+ #: ../../library/dataclasses.rst:720
952951msgid ""
953952"Note that the two instances of class :class:`!C` share the same class "
954953"variable :attr:`!x`, as expected."
955954msgstr "请注意类 :class:`!C` 的两个实例将共享同一个类变量 :attr:`!x`,正如预期的那样。"
956955
957- #: ../../library/dataclasses.rst:722
956+ #: ../../library/dataclasses.rst:723
958957msgid "Using dataclasses, *if* this code was valid::"
959958msgstr "使用数据类,*如果* 此代码有效:"
960959
961- #: ../../library/dataclasses.rst:730
960+ #: ../../library/dataclasses.rst:731
962961msgid "it would generate code similar to::"
963962msgstr "它生成的代码类似于::"
964963
965- #: ../../library/dataclasses.rst:741
964+ #: ../../library/dataclasses.rst:742
966965msgid ""
967966"This has the same issue as the original example using class :class:`!C`. "
968967"That is, two instances of class :class:`!D` that do not specify a value for "
@@ -980,13 +979,13 @@ msgstr ""
980979"数据类没有任何通用方式来检测这种情况。 相反地,:func:`@dataclass <dataclass>` 装饰器在检测到不可哈希的默认形参时将会引发"
981980" :exc:`ValueError`。 这一行为假定如果一个值是不可哈希的,则它就是可变对象。 这是一个部分解决方案,但它确实能防止许多常见错误。"
982981
983- #: ../../library/dataclasses.rst:752
982+ #: ../../library/dataclasses.rst:753
984983msgid ""
985984"Using default factory functions is a way to create new instances of mutable "
986985"types as default values for fields::"
987986msgstr "使用默认工厂函数是一种创建可变类型新实例的方法,并将其作为字段的默认值::"
988987
989- #: ../../library/dataclasses.rst:761
988+ #: ../../library/dataclasses.rst:762
990989msgid ""
991990"Instead of looking for and disallowing objects of type :class:`list`, "
992991":class:`dict`, or :class:`set`, unhashable objects are now not allowed as "
@@ -995,17 +994,17 @@ msgstr ""
995994"现在不再是寻找并阻止使用类型为 :class:`list`, :class:`dict` 或 :class:`set` "
996995"的对象,而是不允许将不可哈希的对象用作默认值。 就是不可哈希性被作为不可变性的近似物了。"
997996
998- #: ../../library/dataclasses.rst:768
997+ #: ../../library/dataclasses.rst:769
999998msgid "Descriptor-typed fields"
1000999msgstr "描述器类型的字段"
10011000
1002- #: ../../library/dataclasses.rst:770
1001+ #: ../../library/dataclasses.rst:771
10031002msgid ""
10041003"Fields that are assigned :ref:`descriptor objects <descriptors>` as their "
10051004"default value have the following special behaviors:"
10061005msgstr "当字段被 :ref:`描述器对象 <descriptors>` 赋值为默认值时会遵循以下行为:"
10071006
1008- #: ../../library/dataclasses.rst:773
1007+ #: ../../library/dataclasses.rst:774
10091008msgid ""
10101009"The value for the field passed to the dataclass's :meth:`~object.__init__` "
10111010"method is passed to the descriptor's :meth:`~object.__set__` method rather "
@@ -1014,7 +1013,7 @@ msgstr ""
10141013"传递给数据类的 :meth:`~object.__init__` 方法的字段值会被传递给描述器的 :meth:`~object.__set__` "
10151014"方法而不会覆盖描述器对象。"
10161015
1017- #: ../../library/dataclasses.rst:777
1016+ #: ../../library/dataclasses.rst:778
10181017msgid ""
10191018"Similarly, when getting or setting the field, the descriptor's "
10201019":meth:`~object.__get__` or :meth:`!__set__` method is called rather than "
@@ -1023,7 +1022,7 @@ msgstr ""
10231022"类似地,当获取或设置字段值时,将调用描述器的 :meth:`~object.__get__` 或 :meth:`!__set__` "
10241023"方法而不是返回或重写描述器对象。"
10251024
1026- #: ../../library/dataclasses.rst:781
1025+ #: ../../library/dataclasses.rst:782
10271026msgid ""
10281027"To determine whether a field contains a default value, :func:`@dataclass "
10291028"<dataclass>` will call the descriptor's :meth:`!__get__` method using its "
@@ -1037,7 +1036,7 @@ msgstr ""
10371036"如果在此情况下描述器返回了一个值,它将被用作字段的默认值。 另一方面,如果在此情况下描述器引发了 "
10381037":exc:`AttributeError`,则不会为字段提供默认值。"
10391038
1040- #: ../../library/dataclasses.rst:816
1039+ #: ../../library/dataclasses.rst:817
10411040msgid ""
10421041"Note that if a field is annotated with a descriptor type, but is not "
10431042"assigned a descriptor object as its default value, the field will act like a"
0 commit comments