@@ -8,7 +8,7 @@ msgstr ""
8
8
"Project-Id-Version : Python 3.12\n "
9
9
"Report-Msgid-Bugs-To : \n "
10
10
"POT-Creation-Date : 2023-11-09 00:04+0000\n "
11
- "PO-Revision-Date : 2023-12-15 10:37 +0800\n "
11
+ "PO-Revision-Date : 2023-12-15 14:19 +0800\n "
12
12
"Last-Translator : RockLeon <therockleona@gmail.com>\n "
13
13
"Language-Team : Chinese - TAIWAN (https://github.com/python/python-docs-zh- "
14
14
"tw)\n "
@@ -723,10 +723,12 @@ msgid ""
723
723
"for each position. In the following example, ``MyIterable`` is not generic "
724
724
"but implicitly inherits from ``Iterable[Any]``:"
725
725
msgstr ""
726
+ "若使用泛型類別卻沒有特指型別參數,則會將每個位子視為 :data:`Any`。在下列的範"
727
+ "例中 ``MyIterable`` 不是泛型,但隱性繼承了 ``Iterable[Any]``: ::"
726
728
727
729
#: ../../library/typing.rst:608
728
730
msgid "User-defined generic type aliases are also supported. Examples::"
729
- msgstr ""
731
+ msgstr "使用者定義的泛型型別別名也有支援。例如: :: "
730
732
731
733
#: ../../library/typing.rst:623
732
734
msgid ""
@@ -736,14 +738,16 @@ msgstr "為了向後相容性,泛型型別別名可以透過簡單的賦值來
736
738
737
739
#: ../../library/typing.rst:632
738
740
msgid ":class:`Generic` no longer has a custom metaclass."
739
- msgstr ""
741
+ msgstr ":class:`Generic` 不再是一個自訂的 metaclass。 "
740
742
741
743
#: ../../library/typing.rst:635
742
744
msgid ""
743
745
"Syntactic support for generics and type aliases is new in version 3.12. "
744
746
"Previously, generic classes had to explicitly inherit from :class:`Generic` "
745
747
"or contain a type variable in one of their bases."
746
748
msgstr ""
749
+ "在版本 3.12 新增了泛型及型別別名的語法支援。在之前的版本中,泛型類別必須顯性"
750
+ "繼承 :class:`Generic` 或是包含一個型別變數在基底類別 (base) 當中。"
747
751
748
752
#: ../../library/typing.rst:640
749
753
msgid ""
@@ -754,12 +758,18 @@ msgid ""
754
758
"The one exception to this is that a list of types can be used to substitute "
755
759
"a :class:`ParamSpec`::"
756
760
msgstr ""
761
+ "使用者定義的參數運算式 (parameter expression) 泛型一樣有支援,透過 ``[**P]`` "
762
+ "格式的參數規格變數來進行表示。對於上述作為參數規格變數的型別變數,將持續被型"
763
+ "別模組視為一個特定的型別變數。對此,其中一個例外是一個型別列表可以替代 :"
764
+ "class:`ParamSpec`: ::"
757
765
758
766
#: ../../library/typing.rst:651
759
767
msgid ""
760
768
"Classes generic over a :class:`ParamSpec` can also be created using explicit "
761
769
"inheritance from :class:`Generic`. In this case, ``**`` is not used::"
762
770
msgstr ""
771
+ "具有 :class:`ParamSpec` 的泛型類別可以透過顯示繼承 :class:`Generic` 進行建"
772
+ "立。在這種情況下,不需要使用 ``**``: ::"
763
773
764
774
#: ../../library/typing.rst:661
765
775
msgid ""
@@ -769,19 +779,27 @@ msgid ""
769
779
"Type2, ...]`` for aesthetic reasons. Internally, the latter is converted to "
770
780
"the former, so the following are equivalent::"
771
781
msgstr ""
782
+ "另外一個 :class:`TypeVar` 以及 :class:`ParamSpec` 之間的差異是,基於美觀因"
783
+ "素,只有一個參數規格變數的泛型可以接受如 ``X[[Type1, Type2, ...]]`` 以及 "
784
+ "``X[Type1, Type2, ...]`` 的參數列表。在內部中,後者會被轉換為前者,所以在下方"
785
+ "的範例中為相等的: ::"
772
786
773
787
#: ../../library/typing.rst:674
774
788
msgid ""
775
789
"Note that generics with :class:`ParamSpec` may not have correct "
776
790
"``__parameters__`` after substitution in some cases because they are "
777
791
"intended primarily for static type checking."
778
792
msgstr ""
793
+ "請記得,具有 :class:`ParamSpec` 的泛型在某些情況下替換之後可能不會有正確的 "
794
+ "``__parameters__``,因為參數規格主要還是用於靜態型別檢查。"
779
795
780
796
#: ../../library/typing.rst:678
781
797
msgid ""
782
798
":class:`Generic` can now be parameterized over parameter expressions. See :"
783
799
"class:`ParamSpec` and :pep:`612` for more details."
784
800
msgstr ""
801
+ ":class:`Generic` 現在可以透過參數運算式來進行參數化。詳細內容請見 :class:"
802
+ "`ParamSpec` 以及 :pep:`612`。"
785
803
786
804
#: ../../library/typing.rst:682
787
805
msgid ""
@@ -790,6 +808,9 @@ msgid ""
790
808
"parameterizing generics is cached, and most types in the typing module are :"
791
809
"term:`hashable` and comparable for equality."
792
810
msgstr ""
811
+ "一個使用者定義的泛型類別可以將 ABC 作為他們的基底類別,且不會有 metaclass 衝"
812
+ "突。泛型的 metaclass 則不支援。參數化泛型的輸出將被存為快取,而在型別模組中多"
813
+ "數的型別皆為 :term:`hashable` 且可以比較相等性。"
793
814
794
815
#: ../../library/typing.rst:689
795
816
msgid "The :data:`Any` type"
@@ -801,12 +822,16 @@ msgid ""
801
822
"every type as being compatible with :data:`Any` and :data:`Any` as being "
802
823
"compatible with every type."
803
824
msgstr ""
825
+ ":data:`Any` 是一種特別的型別。一個靜態型別檢查器會將每個型別視為可相容於 :"
826
+ "data:`Any` 且 :data:`Any` 也可以相容於每個型別。"
804
827
805
828
#: ../../library/typing.rst:695
806
829
msgid ""
807
830
"This means that it is possible to perform any operation or method call on a "
808
831
"value of type :data:`Any` and assign it to any variable::"
809
832
msgstr ""
833
+ "這意味著如果在一個為 :data:`Any` 的值上執行任何操作或呼叫方法是可行的,且可以"
834
+ "賦值給任意變數: ::"
810
835
811
836
#: ../../library/typing.rst:713
812
837
msgid ""
@@ -816,18 +841,23 @@ msgid ""
816
841
"declared to be of type :class:`str` and receives an :class:`int` value at "
817
842
"runtime!"
818
843
msgstr ""
844
+ "請注意,當賦予型別為 :data:`Any` 的值更精確的型別時,將不會執行任何型別檢查。"
845
+ "舉例來說,靜態型別檢查器不會在 runtime 中,將 ``a`` 賦值給 ``s`` 的情況下回報"
846
+ "錯誤,儘管 ``s`` 是被宣告為型別 :class:`str` 卻接收到 :class:`int` 的值!"
819
847
820
848
#: ../../library/typing.rst:719
821
849
msgid ""
822
850
"Furthermore, all functions without a return type or parameter types will "
823
851
"implicitly default to using :data:`Any`::"
824
- msgstr ""
852
+ msgstr "另外,所有缺少回傳型別或參數型別的函式將會隱性預設為 :data:`Any`: :: "
825
853
826
854
#: ../../library/typing.rst:732
827
855
msgid ""
828
856
"This behavior allows :data:`Any` to be used as an *escape hatch* when you "
829
857
"need to mix dynamically and statically typed code."
830
858
msgstr ""
859
+ "當你需要混和動態及靜態的型別程式碼,這個行為允許 :data:`Any` 被當作一個\\ *緊"
860
+ "急出口 (escape hatch)*\\ 使用。"
831
861
832
862
#: ../../library/typing.rst:735
833
863
msgid ""
@@ -836,6 +866,9 @@ msgid ""
836
866
"unlike :data:`Any`, the reverse is not true: :class:`object` is *not* a "
837
867
"subtype of every other type."
838
868
msgstr ""
869
+ ":data:`Any` 的行為對比 :class:`object` 的行為。與 :data:`Any` 相似,所有的型"
870
+ "別會作為 :class:`object` 的子型別。然而,不像 :data:`Any`,反之不亦然::"
871
+ "class:`object` 並\\ *不是*\\ 一個其他型別的子型別。"
839
872
840
873
#: ../../library/typing.rst:740
841
874
msgid ""
@@ -844,12 +877,17 @@ msgid ""
844
877
"it as a return value) of a more specialized type is a type error. For "
845
878
"example::"
846
879
msgstr ""
880
+ "這意味著當一個值的型別為 :class:`object` 時,型別檢查器會拒絕幾乎所有的操作,"
881
+ "並將賦予這個值到一個特定型別變數(或是當作回傳值使用)視為一個型別錯誤。舉例"
882
+ "來說: ::"
847
883
848
884
#: ../../library/typing.rst:762
849
885
msgid ""
850
886
"Use :class:`object` to indicate that a value could be any type in a typesafe "
851
887
"manner. Use :data:`Any` to indicate that a value is dynamically typed."
852
888
msgstr ""
889
+ "使用 :class:`object` ,將指出在型別安全 (typesafe) 的習慣之下一個值可以為任意"
890
+ "型別。使用 :data:`Any`,將指出這個值是個動態型別。"
853
891
854
892
#: ../../library/typing.rst:767
855
893
msgid "Nominal vs structural subtyping"
0 commit comments