6
6
msgstr ""
7
7
"Project-Id-Version : Python 3.12\n "
8
8
"Report-Msgid-Bugs-To : \n "
9
- "POT-Creation-Date : 2023-12-21 00:03 +0000\n "
10
- "PO-Revision-Date : 2023-11-06 10:51 +0800\n "
9
+ "POT-Creation-Date : 2023-11-09 00:04 +0000\n "
10
+ "PO-Revision-Date : 2023-12-15 14:45 +0800\n "
11
11
"Last-Translator : RockLeon <therockleona@gmail.com>\n "
12
12
"Language-Team : Chinese - TAIWAN (https://github.com/python/python-docs-zh- "
13
13
"tw)\n "
@@ -622,7 +622,7 @@ msgstr ""
622
622
623
623
#: ../../library/typing.rst:457
624
624
msgid "The type of class objects"
625
- msgstr ""
625
+ msgstr "類別物件的型別 "
626
626
627
627
#: ../../library/typing.rst:459
628
628
msgid ""
@@ -631,86 +631,103 @@ msgid ""
631
631
"<Type>`) may accept values that are classes themselves -- specifically, it "
632
632
"will accept the *class object* of ``C``. For example::"
633
633
msgstr ""
634
+ "一個變數被註釋為 ``C`` 可以接受一個型別為 ``C`` 的值。相對的,一個變數備註解"
635
+ "為 ``type[C]`` \\ (或 :class:`typing.Type[C] <Type>`)\\ 可以接受本身為該類"
636
+ "別的值 -- 具體來說,他可能會接受 ``C`` 的\\ *類別物件*\\ 。舉例來說: ::"
634
637
635
638
#: ../../library/typing.rst:469
636
639
msgid "Note that ``type[C]`` is covariant::"
637
- msgstr ""
640
+ msgstr "請記得 ``type[C]`` 是共變 (covariant) 的: :: "
638
641
639
642
#: ../../library/typing.rst:485
640
643
msgid ""
641
644
"The only legal parameters for :class:`type` are classes, :data:`Any`, :ref:"
642
645
"`type variables <generics>`, and unions of any of these types. For example::"
643
646
msgstr ""
647
+ ":class:`type` 僅有的合法參數是類別、:data:`Any`、:ref:`型別變數 "
648
+ "<generics>`\\ 以及這些型別任意組合成的聯集。舉例來說: ::"
644
649
645
650
#: ../../library/typing.rst:497
646
651
msgid ""
647
652
"``type[Any]`` is equivalent to :class:`type`, which is the root of Python's :"
648
653
"ref:`metaclass hierarchy <metaclasses>`."
649
654
msgstr ""
655
+ "``type[Any]`` 等價於 :class:`type` ,其為 Python :ref:`metaclass 階層結"
656
+ "構 (hierachy) <metaclasses>`。"
650
657
651
658
#: ../../library/typing.rst:503
652
659
msgid "User-defined generic types"
653
- msgstr ""
660
+ msgstr "使用者定義泛型型別 "
654
661
655
662
#: ../../library/typing.rst:505
656
663
msgid "A user-defined class can be defined as a generic class."
657
- msgstr ""
664
+ msgstr "一個使用者定義的類別可以被定義成一個泛型類別。 "
658
665
659
666
#: ../../library/typing.rst:528
660
667
msgid ""
661
668
"This syntax indicates that the class ``LoggedVar`` is parameterised around a "
662
669
"single :ref:`type variable <typevar>` ``T`` . This also makes ``T`` valid as "
663
670
"a type within the class body."
664
671
msgstr ""
672
+ "這個語法指出類別 ``LoggedVar`` 透過一個單一的 :ref:`型別變數 <typevar>` "
673
+ "``T`` 進行參數化 (parameterised)。這使得 ``T`` 在類別中有效的成為型別。"
665
674
666
675
#: ../../library/typing.rst:532
667
676
msgid ""
668
677
"Generic classes implicitly inherit from :class:`Generic`. For compatibility "
669
678
"with Python 3.11 and lower, it is also possible to inherit explicitly from :"
670
679
"class:`Generic` to indicate a generic class::"
671
680
msgstr ""
681
+ "泛型類別隱性繼承了 :class:`Generic`。為了相容 Python 3.11 及更早版本,也可以"
682
+ "明確的繼承 :class:`Generic` 並指出是一個泛型類別: ::"
672
683
673
684
#: ../../library/typing.rst:543
674
685
msgid ""
675
686
"Generic classes have :meth:`~object.__class_getitem__` methods, meaning they "
676
687
"can be parameterised at runtime (e.g. ``LoggedVar[int]`` below)::"
677
688
msgstr ""
689
+ "泛型類別有 :meth:`~object.__class_getitem__` 方法,其意味著可以在 runtime 進"
690
+ "行參數化(如下述的 ``LoggedVar[int]``): ::"
678
691
679
692
#: ../../library/typing.rst:552
680
693
msgid ""
681
694
"A generic type can have any number of type variables. All varieties of :"
682
695
"class:`TypeVar` are permissible as parameters for a generic type::"
683
696
msgstr ""
697
+ "一個泛型型別可以有任意數量的型別變數。所有種類的 :class:`TypeVar` 都可以作為"
698
+ "泛型型別的參數: ::"
684
699
685
700
#: ../../library/typing.rst:567
686
701
msgid ""
687
702
"Each type variable argument to :class:`Generic` must be distinct. This is "
688
703
"thus invalid::"
689
- msgstr ""
704
+ msgstr ":class:`Generic` 的每個型別變數引數必不相同。因此以下是無效的: :: "
690
705
691
706
#: ../../library/typing.rst:581
692
707
msgid "Generic classes can also inherit from other classes::"
693
- msgstr ""
708
+ msgstr "泛型類別亦可以繼承其他類別: :: "
694
709
695
710
#: ../../library/typing.rst:588
696
711
msgid ""
697
712
"When inheriting from generic classes, some type parameters could be fixed::"
698
- msgstr ""
713
+ msgstr "當繼承泛型類別時,部份的型別參數可固定: :: "
699
714
700
715
#: ../../library/typing.rst:595
701
716
msgid "In this case ``MyDict`` has a single parameter, ``T``."
702
- msgstr ""
717
+ msgstr "在這種情況下 ``MyDict`` 有一個單一的參數 ``T``。 "
703
718
704
719
#: ../../library/typing.rst:597
705
720
msgid ""
706
721
"Using a generic class without specifying type parameters assumes :data:`Any` "
707
722
"for each position. In the following example, ``MyIterable`` is not generic "
708
723
"but implicitly inherits from ``Iterable[Any]``:"
709
724
msgstr ""
725
+ "若使用泛型類別卻沒有特指型別參數,則會將每個位置視為 :data:`Any`。在下列的範"
726
+ "例中 ``MyIterable`` 不是泛型,但隱性繼承了 ``Iterable[Any]``: ::"
710
727
711
728
#: ../../library/typing.rst:608
712
729
msgid "User-defined generic type aliases are also supported. Examples::"
713
- msgstr ""
730
+ msgstr "使用者定義的泛型型別別名也有支援。例如: :: "
714
731
715
732
#: ../../library/typing.rst:623
716
733
msgid ""
@@ -720,14 +737,16 @@ msgstr "為了向後相容性,泛型型別別名可以透過簡單的賦值來
720
737
721
738
#: ../../library/typing.rst:632
722
739
msgid ":class:`Generic` no longer has a custom metaclass."
723
- msgstr ""
740
+ msgstr ":class:`Generic` 不再是一個自訂的 metaclass。 "
724
741
725
742
#: ../../library/typing.rst:635
726
743
msgid ""
727
744
"Syntactic support for generics and type aliases is new in version 3.12. "
728
745
"Previously, generic classes had to explicitly inherit from :class:`Generic` "
729
746
"or contain a type variable in one of their bases."
730
747
msgstr ""
748
+ "在版本 3.12 新增了泛型及型別別名的語法支援。在之前的版本中,泛型類別必須顯性"
749
+ "繼承 :class:`Generic` 或是包含一個型別變數在基底類別 (base) 當中。"
731
750
732
751
#: ../../library/typing.rst:640
733
752
msgid ""
@@ -738,12 +757,18 @@ msgid ""
738
757
"The one exception to this is that a list of types can be used to substitute "
739
758
"a :class:`ParamSpec`::"
740
759
msgstr ""
760
+ "使用者定義的參數運算式 (parameter expression) 泛型一樣有支援,透過 ``[**P]`` "
761
+ "格式的參數規格變數來進行表示。對於上述作為參數規格變數的型別變數,將持續被型"
762
+ "別模組視為一個特定的型別變數。對此,其中一個例外是一個型別列表可以替代 :"
763
+ "class:`ParamSpec`: ::"
741
764
742
765
#: ../../library/typing.rst:651
743
766
msgid ""
744
767
"Classes generic over a :class:`ParamSpec` can also be created using explicit "
745
768
"inheritance from :class:`Generic`. In this case, ``**`` is not used::"
746
769
msgstr ""
770
+ "具有 :class:`ParamSpec` 的泛型類別可以透過顯性繼承 :class:`Generic` 進行建"
771
+ "立。在這種情況下,不需要使用 ``**``: ::"
747
772
748
773
#: ../../library/typing.rst:661
749
774
msgid ""
@@ -753,19 +778,27 @@ msgid ""
753
778
"Type2, ...]`` for aesthetic reasons. Internally, the latter is converted to "
754
779
"the former, so the following are equivalent::"
755
780
msgstr ""
781
+ "另外一個 :class:`TypeVar` 以及 :class:`ParamSpec` 之間的差異是,基於美觀因"
782
+ "素,只有一個參數規格變數的泛型可以接受如 ``X[[Type1, Type2, ...]]`` 以及 "
783
+ "``X[Type1, Type2, ...]`` 的參數列表。在內部中,後者會被轉換為前者,所以在下方"
784
+ "的範例中為相等的: ::"
756
785
757
786
#: ../../library/typing.rst:674
758
787
msgid ""
759
788
"Note that generics with :class:`ParamSpec` may not have correct "
760
789
"``__parameters__`` after substitution in some cases because they are "
761
790
"intended primarily for static type checking."
762
791
msgstr ""
792
+ "請記得,具有 :class:`ParamSpec` 的泛型在某些情況下替換之後可能不會有正確的 "
793
+ "``__parameters__``,因為參數規格主要還是用於靜態型別檢查。"
763
794
764
795
#: ../../library/typing.rst:678
765
796
msgid ""
766
797
":class:`Generic` can now be parameterized over parameter expressions. See :"
767
798
"class:`ParamSpec` and :pep:`612` for more details."
768
799
msgstr ""
800
+ ":class:`Generic` 現在可以透過參數運算式來進行參數化。詳細內容請見 :class:"
801
+ "`ParamSpec` 以及 :pep:`612`。"
769
802
770
803
#: ../../library/typing.rst:682
771
804
msgid ""
@@ -774,6 +807,9 @@ msgid ""
774
807
"parameterizing generics is cached, and most types in the typing module are :"
775
808
"term:`hashable` and comparable for equality."
776
809
msgstr ""
810
+ "一個使用者定義的泛型類別可以將 ABC 作為他們的基底類別,且不會有 metaclass 衝"
811
+ "突。泛型的 metaclass 則不支援。參數化泛型的輸出將被存為快取,而在型別模組中多"
812
+ "數的型別皆為 :term:`hashable` 且可以比較相等性。"
777
813
778
814
#: ../../library/typing.rst:689
779
815
msgid "The :data:`Any` type"
@@ -785,12 +821,16 @@ msgid ""
785
821
"every type as being compatible with :data:`Any` and :data:`Any` as being "
786
822
"compatible with every type."
787
823
msgstr ""
824
+ ":data:`Any` 是一種特別的型別。一個靜態型別檢查器會將每個型別視為可相容於 :"
825
+ "data:`Any` 且 :data:`Any` 也可以相容於每個型別。"
788
826
789
827
#: ../../library/typing.rst:695
790
828
msgid ""
791
829
"This means that it is possible to perform any operation or method call on a "
792
830
"value of type :data:`Any` and assign it to any variable::"
793
831
msgstr ""
832
+ "這意味著如果在一個為 :data:`Any` 的值上執行任何操作或呼叫方法是可行的,且可以"
833
+ "賦值給任意變數: ::"
794
834
795
835
#: ../../library/typing.rst:713
796
836
msgid ""
@@ -800,18 +840,23 @@ msgid ""
800
840
"declared to be of type :class:`str` and receives an :class:`int` value at "
801
841
"runtime!"
802
842
msgstr ""
843
+ "請注意,當賦予型別為 :data:`Any` 的值更精確的型別時,將不會執行任何型別檢查。"
844
+ "舉例來說,靜態型別檢查器不會在 runtime 中,將 ``a`` 賦值給 ``s`` 的情況下回報"
845
+ "錯誤,儘管 ``s`` 是被宣告為型別 :class:`str` 卻接收到 :class:`int` 的值!"
803
846
804
847
#: ../../library/typing.rst:719
805
848
msgid ""
806
849
"Furthermore, all functions without a return type or parameter types will "
807
850
"implicitly default to using :data:`Any`::"
808
- msgstr ""
851
+ msgstr "另外,所有缺少回傳型別或參數型別的函式將會隱性預設為 :data:`Any`: :: "
809
852
810
853
#: ../../library/typing.rst:732
811
854
msgid ""
812
855
"This behavior allows :data:`Any` to be used as an *escape hatch* when you "
813
856
"need to mix dynamically and statically typed code."
814
857
msgstr ""
858
+ "當你需要混和動態及靜態的型別程式碼,這個行為允許 :data:`Any` 被當作一個\\ *緊"
859
+ "急出口 (escape hatch)*\\ 使用。"
815
860
816
861
#: ../../library/typing.rst:735
817
862
msgid ""
@@ -820,6 +865,9 @@ msgid ""
820
865
"unlike :data:`Any`, the reverse is not true: :class:`object` is *not* a "
821
866
"subtype of every other type."
822
867
msgstr ""
868
+ ":data:`Any` 的行為對比 :class:`object` 的行為。與 :data:`Any` 相似,所有的型"
869
+ "別會作為 :class:`object` 的子型別。然而,不像 :data:`Any`,反之不亦然::"
870
+ "class:`object` 並\\ *不是*\\ 一個其他型別的子型別。"
823
871
824
872
#: ../../library/typing.rst:740
825
873
msgid ""
@@ -828,12 +876,17 @@ msgid ""
828
876
"it as a return value) of a more specialized type is a type error. For "
829
877
"example::"
830
878
msgstr ""
879
+ "這意味著當一個值的型別為 :class:`object` 時,型別檢查器會拒絕幾乎所有的操作,"
880
+ "並將賦予這個值到一個特定型別變數(或是當作回傳值使用)視為一個型別錯誤。舉例"
881
+ "來說: ::"
831
882
832
883
#: ../../library/typing.rst:762
833
884
msgid ""
834
885
"Use :class:`object` to indicate that a value could be any type in a typesafe "
835
886
"manner. Use :data:`Any` to indicate that a value is dynamically typed."
836
887
msgstr ""
888
+ "使用 :class:`object` ,將指出在型別安全 (typesafe) 的習慣之下一個值可以為任意"
889
+ "型別。使用 :data:`Any`,將指出這個值是個動態型別。"
837
890
838
891
#: ../../library/typing.rst:767
839
892
msgid "Nominal vs structural subtyping"
@@ -1196,7 +1249,7 @@ msgstr ""
1196
1249
1197
1250
#: ../../library/typing.rst:1166
1198
1251
msgid ":class:`ParamSpec`"
1199
- msgstr ":class:`ParamSpec`。 "
1252
+ msgstr ":class:`ParamSpec`"
1200
1253
1201
1254
#: ../../library/typing.rst:1167 ../../library/typing.rst:1929
1202
1255
msgid ":ref:`annotating-callables`"
@@ -3613,7 +3666,7 @@ msgstr ":gh:`92332`"
3613
3666
3614
3667
#: ../../library/typing.rst:3683
3615
3668
msgid ":class:`typing.Hashable` and :class:`typing.Sized`"
3616
- msgstr ":class:`typing.Hashable` 和 :class:`typing.Sized`。 "
3669
+ msgstr ":class:`typing.Hashable` 和 :class:`typing.Sized`"
3617
3670
3618
3671
#: ../../library/typing.rst:3684 ../../library/typing.rst:3688
3619
3672
msgid "3.12"
0 commit comments