@@ -11,7 +11,7 @@ msgid ""
11
11
msgstr ""
12
12
"Project-Id-Version : Python 3.12\n "
13
13
"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 "
15
15
"PO-Revision-Date : 2024-05-11 00:33+0000\n "
16
16
"Last-Translator : Rafael Fontenelle <rffontenelle@gmail.com>, 2024\n "
17
17
"Language-Team : Chinese (China) (https://app.transifex.com/python-doc/teams/5390/zh_CN/)\n "
@@ -833,16 +833,15 @@ msgstr ""
833
833
msgid ""
834
834
"There is a tiny performance penalty when using ``frozen=True``: "
835
835
":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"
837
838
msgstr ""
838
- "在使用 ``frozen=True`` 时会有微小的性能损失: :meth:`~object.__init__` "
839
- "不能使用简单赋值来初始化字段,而必须使用 :meth:`!__setattr__`。"
840
839
841
- #: ../../library/dataclasses.rst:621
840
+ #: ../../library/dataclasses.rst:622
842
841
msgid "Inheritance"
843
842
msgstr "继承"
844
843
845
- #: ../../library/dataclasses.rst:623
844
+ #: ../../library/dataclasses.rst:624
846
845
msgid ""
847
846
"When the dataclass is being created by the :func:`@dataclass <dataclass>` "
848
847
"decorator, it looks through all of the class's base classes in reverse MRO "
@@ -857,7 +856,7 @@ msgstr ""
857
856
":class:`object` 开始)查看它的所有基类,并将找到的每个数据类的字段添加到一个有序映射中。 所有生成的方法都将使用这个有序映射。 "
858
857
"字段会遵守它们被插入的顺序,因此派生类会重写基类。 一个例子::"
859
858
860
- #: ../../library/dataclasses.rst:643
859
+ #: ../../library/dataclasses.rst:644
861
860
msgid ""
862
861
"The final list of fields is, in order, :attr:`!x`, :attr:`!y`, :attr:`!z`. "
863
862
"The final type of :attr:`!x` is :class:`int`, as specified in class "
@@ -866,17 +865,17 @@ msgstr ""
866
865
"最终的字段列表依次是 :attr:`!x`, :attr:`!y`, :attr:`!z`。 最终的 :attr:`!x` 类型是 "
867
866
":class:`int`,正如类 :class:`!C` 中所指定的。"
868
867
869
- #: ../../library/dataclasses.rst:646
868
+ #: ../../library/dataclasses.rst:647
870
869
msgid ""
871
870
"The generated :meth:`~object.__init__` method for :class:`!C` will look "
872
871
"like::"
873
872
msgstr "为 :class:`!C` 生成的 :meth:`~object.__init__` 方法看起来像是这样::"
874
873
875
- #: ../../library/dataclasses.rst:651
874
+ #: ../../library/dataclasses.rst:652
876
875
msgid "Re-ordering of keyword-only parameters in :meth:`!__init__`"
877
876
msgstr ":meth:`!__init__` 中仅限关键字形参的重新排序"
878
877
879
- #: ../../library/dataclasses.rst:653
878
+ #: ../../library/dataclasses.rst:654
880
879
msgid ""
881
880
"After the parameters needed for :meth:`~object.__init__` are computed, any "
882
881
"keyword-only parameters are moved to come after all regular (non-keyword-"
@@ -886,7 +885,7 @@ msgstr ""
886
885
"在计算出 :meth:`~object.__init__` 所需要的形参之后,任何仅限关键字形参会被移至所有常规(非仅限关键字)形参的后面。 这是 "
887
886
"Python 中实现仅限关键字形参所要求的:它们必须位于非仅限关键字形参之后。"
888
887
889
- #: ../../library/dataclasses.rst:659
888
+ #: ../../library/dataclasses.rst:660
890
889
msgid ""
891
890
"In this example, :attr:`!Base.y`, :attr:`!Base.w`, and :attr:`!D.t` are "
892
891
"keyword-only fields, and :attr:`!Base.x` and :attr:`!D.z` are regular "
@@ -895,29 +894,29 @@ msgstr ""
895
894
"在这个例子中,:attr:`!Base.y`, :attr:`!Base.w` 和 :attr:`!D.t` 是仅限关键字字段,而 "
896
895
":attr:`!Base.x` 和 :attr:`!D.z` 是常规字段::"
897
896
898
- #: ../../library/dataclasses.rst:674
897
+ #: ../../library/dataclasses.rst:675
899
898
msgid ""
900
899
"The generated :meth:`!__init__` method for :class:`!D` will look like::"
901
900
msgstr "为 :class:`!D` 生成的 :meth:`!__init__` 方法看起来像是这样::"
902
901
903
- #: ../../library/dataclasses.rst:678
902
+ #: ../../library/dataclasses.rst:679
904
903
msgid ""
905
904
"Note that the parameters have been re-ordered from how they appear in the "
906
905
"list of fields: parameters derived from regular fields are followed by "
907
906
"parameters derived from keyword-only fields."
908
907
msgstr "请注意形参原来在字段列表中出现的位置已被重新排序:前面是来自常规字段的形参而后面是来自仅限关键字字段的形参。"
909
908
910
- #: ../../library/dataclasses.rst:682
909
+ #: ../../library/dataclasses.rst:683
911
910
msgid ""
912
911
"The relative ordering of keyword-only parameters is maintained in the re-"
913
912
"ordered :meth:`!__init__` parameter list."
914
913
msgstr "仅限关键字形参的相对顺序会在重新排序的 :meth:`!__init__` 列表中保持不变。"
915
914
916
- #: ../../library/dataclasses.rst:687
915
+ #: ../../library/dataclasses.rst:688
917
916
msgid "Default factory functions"
918
917
msgstr "默认工厂函数"
919
918
920
- #: ../../library/dataclasses.rst:689
919
+ #: ../../library/dataclasses.rst:690
921
920
msgid ""
922
921
"If a :func:`field` specifies a *default_factory*, it is called with zero "
923
922
"arguments when a default value for the field is needed. For example, to "
@@ -926,7 +925,7 @@ msgstr ""
926
925
"如果一个 :func:`field` 指定了 *default_factory*,它将在该字段需要默认值时不带参数地被调用。 "
927
926
"例如,要创建一个列表的新实例,则使用::"
928
927
929
- #: ../../library/dataclasses.rst:695
928
+ #: ../../library/dataclasses.rst:696
930
929
msgid ""
931
930
"If a field is excluded from :meth:`~object.__init__` (using ``init=False``) "
932
931
"and the field also specifies *default_factory*, then the default factory "
@@ -938,31 +937,31 @@ msgstr ""
938
937
"*default_factory*,则默认的工厂函数将总是会从生成的 :meth:`!__init__` 函数中被调用。 "
939
938
"发生这种情况是因为没有其他方式能为字段提供初始值。"
940
939
941
- #: ../../library/dataclasses.rst:702
940
+ #: ../../library/dataclasses.rst:703
942
941
msgid "Mutable default values"
943
942
msgstr "可变的默认值"
944
943
945
- #: ../../library/dataclasses.rst:704
944
+ #: ../../library/dataclasses.rst:705
946
945
msgid ""
947
946
"Python stores default member variable values in class attributes. Consider "
948
947
"this example, not using dataclasses::"
949
948
msgstr "Python 在类属性中存储默认成员变量值。思考这个例子,不使用数据类::"
950
949
951
- #: ../../library/dataclasses.rst:719
950
+ #: ../../library/dataclasses.rst:720
952
951
msgid ""
953
952
"Note that the two instances of class :class:`!C` share the same class "
954
953
"variable :attr:`!x`, as expected."
955
954
msgstr "请注意类 :class:`!C` 的两个实例将共享同一个类变量 :attr:`!x`,正如预期的那样。"
956
955
957
- #: ../../library/dataclasses.rst:722
956
+ #: ../../library/dataclasses.rst:723
958
957
msgid "Using dataclasses, *if* this code was valid::"
959
958
msgstr "使用数据类,*如果* 此代码有效:"
960
959
961
- #: ../../library/dataclasses.rst:730
960
+ #: ../../library/dataclasses.rst:731
962
961
msgid "it would generate code similar to::"
963
962
msgstr "它生成的代码类似于::"
964
963
965
- #: ../../library/dataclasses.rst:741
964
+ #: ../../library/dataclasses.rst:742
966
965
msgid ""
967
966
"This has the same issue as the original example using class :class:`!C`. "
968
967
"That is, two instances of class :class:`!D` that do not specify a value for "
@@ -980,13 +979,13 @@ msgstr ""
980
979
"数据类没有任何通用方式来检测这种情况。 相反地,:func:`@dataclass <dataclass>` 装饰器在检测到不可哈希的默认形参时将会引发"
981
980
" :exc:`ValueError`。 这一行为假定如果一个值是不可哈希的,则它就是可变对象。 这是一个部分解决方案,但它确实能防止许多常见错误。"
982
981
983
- #: ../../library/dataclasses.rst:752
982
+ #: ../../library/dataclasses.rst:753
984
983
msgid ""
985
984
"Using default factory functions is a way to create new instances of mutable "
986
985
"types as default values for fields::"
987
986
msgstr "使用默认工厂函数是一种创建可变类型新实例的方法,并将其作为字段的默认值::"
988
987
989
- #: ../../library/dataclasses.rst:761
988
+ #: ../../library/dataclasses.rst:762
990
989
msgid ""
991
990
"Instead of looking for and disallowing objects of type :class:`list`, "
992
991
":class:`dict`, or :class:`set`, unhashable objects are now not allowed as "
@@ -995,17 +994,17 @@ msgstr ""
995
994
"现在不再是寻找并阻止使用类型为 :class:`list`, :class:`dict` 或 :class:`set` "
996
995
"的对象,而是不允许将不可哈希的对象用作默认值。 就是不可哈希性被作为不可变性的近似物了。"
997
996
998
- #: ../../library/dataclasses.rst:768
997
+ #: ../../library/dataclasses.rst:769
999
998
msgid "Descriptor-typed fields"
1000
999
msgstr "描述器类型的字段"
1001
1000
1002
- #: ../../library/dataclasses.rst:770
1001
+ #: ../../library/dataclasses.rst:771
1003
1002
msgid ""
1004
1003
"Fields that are assigned :ref:`descriptor objects <descriptors>` as their "
1005
1004
"default value have the following special behaviors:"
1006
1005
msgstr "当字段被 :ref:`描述器对象 <descriptors>` 赋值为默认值时会遵循以下行为:"
1007
1006
1008
- #: ../../library/dataclasses.rst:773
1007
+ #: ../../library/dataclasses.rst:774
1009
1008
msgid ""
1010
1009
"The value for the field passed to the dataclass's :meth:`~object.__init__` "
1011
1010
"method is passed to the descriptor's :meth:`~object.__set__` method rather "
@@ -1014,7 +1013,7 @@ msgstr ""
1014
1013
"传递给数据类的 :meth:`~object.__init__` 方法的字段值会被传递给描述器的 :meth:`~object.__set__` "
1015
1014
"方法而不会覆盖描述器对象。"
1016
1015
1017
- #: ../../library/dataclasses.rst:777
1016
+ #: ../../library/dataclasses.rst:778
1018
1017
msgid ""
1019
1018
"Similarly, when getting or setting the field, the descriptor's "
1020
1019
":meth:`~object.__get__` or :meth:`!__set__` method is called rather than "
@@ -1023,7 +1022,7 @@ msgstr ""
1023
1022
"类似地,当获取或设置字段值时,将调用描述器的 :meth:`~object.__get__` 或 :meth:`!__set__` "
1024
1023
"方法而不是返回或重写描述器对象。"
1025
1024
1026
- #: ../../library/dataclasses.rst:781
1025
+ #: ../../library/dataclasses.rst:782
1027
1026
msgid ""
1028
1027
"To determine whether a field contains a default value, :func:`@dataclass "
1029
1028
"<dataclass>` will call the descriptor's :meth:`!__get__` method using its "
@@ -1037,7 +1036,7 @@ msgstr ""
1037
1036
"如果在此情况下描述器返回了一个值,它将被用作字段的默认值。 另一方面,如果在此情况下描述器引发了 "
1038
1037
":exc:`AttributeError`,则不会为字段提供默认值。"
1039
1038
1040
- #: ../../library/dataclasses.rst:816
1039
+ #: ../../library/dataclasses.rst:817
1041
1040
msgid ""
1042
1041
"Note that if a field is annotated with a descriptor type, but is not "
1043
1042
"assigned a descriptor object as its default value, the field will act like a"
0 commit comments