@@ -7,8 +7,8 @@ msgstr ""
7
7
"Project-Id-Version : Python 3.12\n "
8
8
"Report-Msgid-Bugs-To : \n "
9
9
"POT-Creation-Date : 2024-03-06 00:03+0000\n "
10
- "PO-Revision-Date : 2023-12-15 14:45 +0800\n "
11
- "Last-Translator : RockLeon <therockleona@gmail.com>\n "
10
+ "PO-Revision-Date : 2024-03-26 11:30 +0800\n "
11
+ "Last-Translator : Li-Hung Wang <therockleona@gmail.com>\n "
12
12
"Language-Team : Chinese - TAIWAN (https://github.com/python/python-docs-zh- "
13
13
"tw)\n "
14
14
"Language : zh_TW\n "
@@ -146,8 +146,8 @@ msgstr "*引入*\\ 在定義函式之外的變數註釋語法,以及 :data:`Cl
146
146
#: ../../library/typing.rst:80
147
147
msgid ":pep:`544`: Protocols: Structural subtyping (static duck typing)"
148
148
msgstr ""
149
- ":pep:`544`: 協定:建構式子型別 (Structural Subtyping) (靜態鴨子型別,"
150
- "Static Duck Typing)"
149
+ ":pep:`544`: 協定:結構子型別 (Structural Subtyping) (靜態鴨子型別,Static "
150
+ "Duck Typing)"
151
151
152
152
#: ../../library/typing.rst:80
153
153
msgid ""
@@ -890,14 +890,16 @@ msgstr ""
890
890
891
891
#: ../../library/typing.rst:767
892
892
msgid "Nominal vs structural subtyping"
893
- msgstr ""
893
+ msgstr "標稱 (nominal) 子型別 vs 結構子型別 "
894
894
895
895
#: ../../library/typing.rst:769
896
896
msgid ""
897
897
"Initially :pep:`484` defined the Python static type system as using *nominal "
898
898
"subtyping*. This means that a class ``A`` is allowed where a class ``B`` is "
899
899
"expected if and only if ``A`` is a subclass of ``B``."
900
900
msgstr ""
901
+ "最初 :pep:`484` 定義 Python 靜態型別系統使用\\ *標稱子型別*。這意味著只有 "
902
+ "``A`` 為 ``B`` 的子類別時,``A`` 才被允許使用在預期是類別 ``B`` 出現的地方。"
901
903
902
904
#: ../../library/typing.rst:773
903
905
msgid ""
@@ -907,6 +909,10 @@ msgid ""
907
909
"unlike what one would normally do in idiomatic dynamically typed Python "
908
910
"code. For example, this conforms to :pep:`484`::"
909
911
msgstr ""
912
+ "這個需求之前也被運用在抽象基底類別,例如 :class:`~collections.abc.Iterable`。"
913
+ "這種方式的問題在於,一個類別需要顯式的標記來支援他們,這並不符合 Python 風"
914
+ "格,也不像一個常見的慣用動態型別 Python 程式碼。舉例來說,下列程式碼符合 :"
915
+ "pep:`484`: ::"
910
916
911
917
#: ../../library/typing.rst:786
912
918
msgid ""
@@ -916,13 +922,19 @@ msgid ""
916
922
"``Iterable[int]`` by static type checkers. This is known as *structural "
917
923
"subtyping* (or static duck-typing)::"
918
924
msgstr ""
925
+ ":pep:`544` 可以透過使用上方的程式碼,且在類別定義時不用顯式基底類別解決這個問"
926
+ "題,讓 ``Bucket`` 被靜態型別檢查器隱性認為是 ``Sized`` 以及 "
927
+ "``Iterable[int]`` 兩者的子型別。這就是眾所周知的\\ *結構子型別*\\ (或是靜態"
928
+ "鴨子型別): ::"
919
929
920
930
#: ../../library/typing.rst:802
921
931
msgid ""
922
932
"Moreover, by subclassing a special class :class:`Protocol`, a user can "
923
933
"define new custom protocols to fully enjoy structural subtyping (see "
924
934
"examples below)."
925
935
msgstr ""
936
+ "而且,基於一個特別的型別 :class:`Protocol` 建立子型別時,使用者可以定義新的"
937
+ "協定並充份發揮結構子型別的優勢(請見下方範例)。"
926
938
927
939
#: ../../library/typing.rst:807
928
940
msgid "Module contents"
@@ -932,54 +944,58 @@ msgstr "模組內容"
932
944
msgid ""
933
945
"The ``typing`` module defines the following classes, functions and "
934
946
"decorators."
935
- msgstr ""
947
+ msgstr "模組 ``typing`` 定義了下列的類別、函式以及裝飾器。 "
936
948
937
949
#: ../../library/typing.rst:812
938
950
msgid "Special typing primitives"
939
- msgstr ""
951
+ msgstr "特別型別原語 (primitive) "
940
952
941
953
#: ../../library/typing.rst:815
942
954
msgid "Special types"
943
- msgstr ""
955
+ msgstr "特別型別 "
944
956
945
957
#: ../../library/typing.rst:817
946
958
msgid ""
947
959
"These can be used as types in annotations. They do not support subscription "
948
960
"using ``[]``."
949
- msgstr ""
961
+ msgstr "這些可以在註釋中做為型別。他們並不支援 ``[]`` 的下標使用。 "
950
962
951
963
#: ../../library/typing.rst:822
952
964
msgid "Special type indicating an unconstrained type."
953
- msgstr ""
965
+ msgstr "特別型別,指出一個不受約束 (unconstrained) 的型別。 "
954
966
955
967
#: ../../library/typing.rst:824
956
968
msgid "Every type is compatible with :data:`Any`."
957
- msgstr ""
969
+ msgstr "所有型別皆與 :data:`Any` 相容。 "
958
970
959
971
#: ../../library/typing.rst:825
960
972
msgid ":data:`Any` is compatible with every type."
961
- msgstr ""
973
+ msgstr ":data:`Any` 相容於所有型別。 "
962
974
963
975
#: ../../library/typing.rst:827
964
976
msgid ""
965
977
":data:`Any` can now be used as a base class. This can be useful for avoiding "
966
978
"type checker errors with classes that can duck type anywhere or are highly "
967
979
"dynamic."
968
980
msgstr ""
981
+ ":data:`Any` 可以作為一個基礎類別。這對於在任何地方使用鴨子型別或是高度動態的"
982
+ "型別,避免型別檢查器的錯誤是非常有用的。"
969
983
970
984
#: ../../library/typing.rst:834
971
985
msgid "A :ref:`constrained type variable <typing-constrained-typevar>`."
972
- msgstr ""
986
+ msgstr "一個 \\ :ref:`不受約束的型別變數 <typing-constrained-typevar>`。 "
973
987
974
988
#: ../../library/typing.rst:836
975
989
msgid "Definition::"
976
- msgstr ""
990
+ msgstr "定義: :: "
977
991
978
992
#: ../../library/typing.rst:840
979
993
msgid ""
980
994
"``AnyStr`` is meant to be used for functions that may accept :class:`str` "
981
995
"or :class:`bytes` arguments but cannot allow the two to mix."
982
996
msgstr ""
997
+ "``AnyStr`` 是對於函式有用的,他可以接受 :class:`str` 或 :class:`bytes` 引數但"
998
+ "不可以將此兩種混合。"
983
999
984
1000
#: ../../library/typing.rst:843 ../../library/typing.rst:934
985
1001
#: ../../library/typing.rst:953 ../../library/typing.rst:1010
@@ -997,10 +1013,13 @@ msgid ""
997
1013
"`Any` type, nor does it mean \" any string\" . In particular, ``AnyStr`` and "
998
1014
"``str | bytes`` are different from each other and have different use cases::"
999
1015
msgstr ""
1016
+ "請注意,儘管他的名稱相近,``AnyStr`` 與 :class:`Any` 型別無關,更不代表是「任"
1017
+ "何字串」的意思。尤其,``AnyStr`` 與 ``str | bytes`` 兩者不同且具有不同的使用"
1018
+ "情境: ::"
1000
1019
1001
1020
#: ../../library/typing.rst:869
1002
1021
msgid "Special type that includes only literal strings."
1003
- msgstr ""
1022
+ msgstr "特別型別,只包含文本字串。 "
1004
1023
1005
1024
#: ../../library/typing.rst:871
1006
1025
msgid ""
@@ -1009,13 +1028,13 @@ msgid ""
1009
1028
"created by composing ``LiteralString``-typed objects is also acceptable as a "
1010
1029
"``LiteralString``."
1011
1030
msgstr ""
1031
+ "任何文本字串都相容於 ``LiteralString``,對於另一個 ``LiteralString`` 亦是如"
1032
+ "此。然而,若是一個型別僅為 ``str`` 的物件則不相容。一個字串若是透過組合多個 "
1033
+ "``LiteralString`` 型別的物件建立,則此字串也可以視為 ``LiteralString``。"
1012
1034
1013
1035
#: ../../library/typing.rst:877 ../../library/typing.rst:1957
1014
1036
msgid "Example:"
1015
- msgstr ""
1016
- "舉例來說:\n"
1017
- "\n"
1018
- "::"
1037
+ msgstr "舉例來說: ::"
1019
1038
1020
1039
#: ../../library/typing.rst:893
1021
1040
msgid ""
@@ -1024,6 +1043,9 @@ msgid ""
1024
1043
"that generate type checker errors could be vulnerable to an SQL injection "
1025
1044
"attack."
1026
1045
msgstr ""
1046
+ "``LiteralString`` 對於敏感的 API 來說是有用的,其中任意的使用者產生的字串可能"
1047
+ "會產生問題。舉例來說,上面兩個案例中產生的型別檢查器錯誤是脆弱的且容易受到 "
1048
+ "SQL 注入攻擊。"
1027
1049
1028
1050
#: ../../library/typing.rst:898
1029
1051
msgid "See :pep:`675` for more details."
@@ -1034,22 +1056,26 @@ msgid ""
1034
1056
"The `bottom type <https://en.wikipedia.org/wiki/Bottom_type>`_, a type that "
1035
1057
"has no members."
1036
1058
msgstr ""
1059
+ "`底部型別 (bottom type) <https://en.wikipedia.org/wiki/Bottom_type>`_,為一個"
1060
+ "型別但沒有任何的成員。"
1037
1061
1038
1062
#: ../../library/typing.rst:907
1039
1063
msgid ""
1040
1064
"This can be used to define a function that should never be called, or a "
1041
1065
"function that never returns::"
1042
- msgstr ""
1066
+ msgstr "這可以被用來定義一個不應被呼叫的函式,或是一個不會回傳的函式: :: "
1043
1067
1044
1068
#: ../../library/typing.rst:927
1045
1069
msgid ""
1046
1070
"On older Python versions, :data:`NoReturn` may be used to express the same "
1047
1071
"concept. ``Never`` was added to make the intended meaning more explicit."
1048
1072
msgstr ""
1073
+ "在舊的 Python 版本當中,:data:`NoReturn` 可以用來當作一樣的概念使用。新增 "
1074
+ "``Never`` 之後,則讓這個含義變得更為明確。"
1049
1075
1050
1076
#: ../../library/typing.rst:932
1051
1077
msgid "Special type indicating that a function never returns."
1052
- msgstr ""
1078
+ msgstr "特別型別,指出一個永不回傳的函式。 "
1053
1079
1054
1080
#: ../../library/typing.rst:941
1055
1081
msgid ""
@@ -1058,16 +1084,19 @@ msgid ""
1058
1084
"the :data:`Never` type should be used for this concept instead. Type "
1059
1085
"checkers should treat the two equivalently."
1060
1086
msgstr ""
1087
+ "``NoReturn`` 可以用來作為一個\\ `底部型別 <https://en.wikipedia.org/wiki/"
1088
+ "Bottom_type>`_,一個沒有值的型別。從 Python 3.11 開始,型別 :data:`Never` 應"
1089
+ "該改用這個概念。型別檢查器應該將這兩種型別視為相等的。"
1061
1090
1062
1091
#: ../../library/typing.rst:951
1063
1092
msgid "Special type to represent the current enclosed class."
1064
- msgstr ""
1093
+ msgstr "特別型別,用來表示當前類別之內 (enclosed class)。 "
1065
1094
1066
1095
#: ../../library/typing.rst:967
1067
1096
msgid ""
1068
1097
"This annotation is semantically equivalent to the following, albeit in a "
1069
1098
"more succinct fashion::"
1070
- msgstr ""
1099
+ msgstr "這個註釋在語意上相等於下列內容,且形式更為簡潔: :: "
1071
1100
1072
1101
#: ../../library/typing.rst:979
1073
1102
msgid ""
@@ -1077,26 +1106,34 @@ msgid ""
1077
1106
"object returned from ``SubclassOfFoo.return_self`` as being of type ``Foo`` "
1078
1107
"rather than ``SubclassOfFoo``."
1079
1108
msgstr ""
1109
+ "一般來說,如果某個東西回傳 ``self`` 如上方的範例所示,你則應該使用 ``Self`` "
1110
+ "做為回傳值的註釋。若 ``Foo.return_self`` 被註釋為回傳 ``\" Foo\" ``,則型別檢查"
1111
+ "器應該推論這個從 ``SubclassOfFoo.return_self`` 回傳的物件為 ``Foo`` 型別,而"
1112
+ "並非回傳 ``SubclassOfFoo`` 型別。"
1080
1113
1081
1114
#: ../../library/typing.rst:985
1082
1115
msgid "Other common use cases include:"
1083
- msgstr ""
1116
+ msgstr "其他常見的使用案例包含: :: "
1084
1117
1085
1118
#: ../../library/typing.rst:987
1086
1119
msgid ""
1087
1120
":class:`classmethod`\\ s that are used as alternative constructors and return "
1088
1121
"instances of the ``cls`` parameter."
1089
1122
msgstr ""
1123
+ ":class:`classmethod` 被用來作為替代的建構函式 (constructor) 並回傳 ``cls`` 參"
1124
+ "數的實例。"
1090
1125
1091
1126
#: ../../library/typing.rst:989
1092
1127
msgid "Annotating an :meth:`~object.__enter__` method which returns self."
1093
- msgstr ""
1128
+ msgstr "註釋一個回傳自己的 :meth:`~object.__enter__` 方法。 "
1094
1129
1095
1130
#: ../../library/typing.rst:991
1096
1131
msgid ""
1097
1132
"You should not use ``Self`` as the return annotation if the method is not "
1098
1133
"guaranteed to return an instance of a subclass when the class is subclassed::"
1099
1134
msgstr ""
1135
+ "當類別被子類別化時,若方法不保證回傳一個子類別的實例,你不應該使用 ``Self`` "
1136
+ "作為回傳註釋: ::"
1100
1137
1101
1138
#: ../../library/typing.rst:1002
1102
1139
msgid "See :pep:`673` for more details."
@@ -1106,14 +1143,17 @@ msgstr "更多細節請見 :pep:`673`。"
1106
1143
msgid ""
1107
1144
"Special annotation for explicitly declaring a :ref:`type alias <type-"
1108
1145
"aliases>`."
1109
- msgstr ""
1146
+ msgstr "做為明確宣告一個 \\ :ref:`型別別名 <type-aliases>` 的特別註釋。 "
1110
1147
1111
1148
#: ../../library/typing.rst:1016
1112
1149
msgid ""
1113
1150
"``TypeAlias`` is particularly useful on older Python versions for annotating "
1114
1151
"aliases that make use of forward references, as it can be hard for type "
1115
1152
"checkers to distinguish these from normal variable assignments:"
1116
1153
msgstr ""
1154
+ "``TypeAlias`` 在舊的 Python 版本中特別有用,其註釋別名可以用來進行傳遞參照 "
1155
+ "(forward reference),因為對於型別檢查器來說,分辨這些別名與一般的變數賦值相當"
1156
+ "困難: ::"
1117
1157
1118
1158
#: ../../library/typing.rst:1036
1119
1159
msgid "See :pep:`613` for more details."
@@ -1129,6 +1169,11 @@ msgid ""
1129
1169
"`TypeAlias` is not currently planned, but users are encouraged to migrate "
1130
1170
"to :keyword:`type` statements."
1131
1171
msgstr ""
1172
+ ":data:`TypeAlias` 被棄用,請改用 :keyword:`type` 陳述式來建立 :class:"
1173
+ "`TypeAliasType` 的實例,其自然可以支援傳遞參照的使用。請注意,雖然 :data:"
1174
+ "`TypeAlias` 以及 :class:`TypeAliasType` 提供相似的用途且具有相似的名稱,他們"
1175
+ "是不同的,且後者不是前者的型別。現在還沒有移除 :data:`TypeAlias` 的計畫,但鼓"
1176
+ "勵使用者們遷移 (migrate) 至 :keyword:`type` 陳述式。"
1132
1177
1133
1178
#: ../../library/typing.rst:1051
1134
1179
msgid "Special forms"
0 commit comments