66msgstr ""
77"Project-Id-Version : Python 3.12\n "
88"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 "
1111"Last-Translator : RockLeon <therockleona@gmail.com>\n "
1212"Language-Team : Chinese - TAIWAN (https://github.com/python/python-docs-zh- "
1313"tw)\n "
@@ -622,7 +622,7 @@ msgstr ""
622622
623623#: ../../library/typing.rst:457
624624msgid "The type of class objects"
625- msgstr ""
625+ msgstr "類別物件的型別 "
626626
627627#: ../../library/typing.rst:459
628628msgid ""
@@ -631,86 +631,103 @@ msgid ""
631631"<Type>`) may accept values that are classes themselves -- specifically, it "
632632"will accept the *class object* of ``C``. For example::"
633633msgstr ""
634+ "一個變數被註釋為 ``C`` 可以接受一個型別為 ``C`` 的值。相對的,一個變數備註解"
635+ "為 ``type[C]`` \\ (或 :class:`typing.Type[C] <Type>`)\\ 可以接受本身為該類"
636+ "別的值 -- 具體來說,他可能會接受 ``C`` 的\\ *類別物件*\\ 。舉例來說: ::"
634637
635638#: ../../library/typing.rst:469
636639msgid "Note that ``type[C]`` is covariant::"
637- msgstr ""
640+ msgstr "請記得 ``type[C]`` 是共變 (covariant) 的: :: "
638641
639642#: ../../library/typing.rst:485
640643msgid ""
641644"The only legal parameters for :class:`type` are classes, :data:`Any`, :ref:"
642645"`type variables <generics>`, and unions of any of these types. For example::"
643646msgstr ""
647+ ":class:`type` 僅有的合法參數是類別、:data:`Any`、:ref:`型別變數 "
648+ "<generics>`\\ 以及這些型別任意組合成的聯集。舉例來說: ::"
644649
645650#: ../../library/typing.rst:497
646651msgid ""
647652"``type[Any]`` is equivalent to :class:`type`, which is the root of Python's :"
648653"ref:`metaclass hierarchy <metaclasses>`."
649654msgstr ""
655+ "``type[Any]`` 等價於 :class:`type` ,其為 Python :ref:`metaclass 階層結"
656+ "構 (hierachy) <metaclasses>`。"
650657
651658#: ../../library/typing.rst:503
652659msgid "User-defined generic types"
653- msgstr ""
660+ msgstr "使用者定義泛型型別 "
654661
655662#: ../../library/typing.rst:505
656663msgid "A user-defined class can be defined as a generic class."
657- msgstr ""
664+ msgstr "一個使用者定義的類別可以被定義成一個泛型類別。 "
658665
659666#: ../../library/typing.rst:528
660667msgid ""
661668"This syntax indicates that the class ``LoggedVar`` is parameterised around a "
662669"single :ref:`type variable <typevar>` ``T`` . This also makes ``T`` valid as "
663670"a type within the class body."
664671msgstr ""
672+ "這個語法指出類別 ``LoggedVar`` 透過一個單一的 :ref:`型別變數 <typevar>` "
673+ "``T`` 進行參數化 (parameterised)。這使得 ``T`` 在類別中有效的成為型別。"
665674
666675#: ../../library/typing.rst:532
667676msgid ""
668677"Generic classes implicitly inherit from :class:`Generic`. For compatibility "
669678"with Python 3.11 and lower, it is also possible to inherit explicitly from :"
670679"class:`Generic` to indicate a generic class::"
671680msgstr ""
681+ "泛型類別隱性繼承了 :class:`Generic`。為了相容 Python 3.11 及更早版本,也可以"
682+ "明確的繼承 :class:`Generic` 並指出是一個泛型類別: ::"
672683
673684#: ../../library/typing.rst:543
674685msgid ""
675686"Generic classes have :meth:`~object.__class_getitem__` methods, meaning they "
676687"can be parameterised at runtime (e.g. ``LoggedVar[int]`` below)::"
677688msgstr ""
689+ "泛型類別有 :meth:`~object.__class_getitem__` 方法,其意味著可以在 runtime 進"
690+ "行參數化(如下述的 ``LoggedVar[int]``): ::"
678691
679692#: ../../library/typing.rst:552
680693msgid ""
681694"A generic type can have any number of type variables. All varieties of :"
682695"class:`TypeVar` are permissible as parameters for a generic type::"
683696msgstr ""
697+ "一個泛型型別可以有任意數量的型別變數。所有種類的 :class:`TypeVar` 都可以作為"
698+ "泛型型別的參數: ::"
684699
685700#: ../../library/typing.rst:567
686701msgid ""
687702"Each type variable argument to :class:`Generic` must be distinct. This is "
688703"thus invalid::"
689- msgstr ""
704+ msgstr ":class:`Generic` 的每個型別變數引數必不相同。因此以下是無效的: :: "
690705
691706#: ../../library/typing.rst:581
692707msgid "Generic classes can also inherit from other classes::"
693- msgstr ""
708+ msgstr "泛型類別亦可以繼承其他類別: :: "
694709
695710#: ../../library/typing.rst:588
696711msgid ""
697712"When inheriting from generic classes, some type parameters could be fixed::"
698- msgstr ""
713+ msgstr "當繼承泛型類別時,部份的型別參數可固定: :: "
699714
700715#: ../../library/typing.rst:595
701716msgid "In this case ``MyDict`` has a single parameter, ``T``."
702- msgstr ""
717+ msgstr "在這種情況下 ``MyDict`` 有一個單一的參數 ``T``。 "
703718
704719#: ../../library/typing.rst:597
705720msgid ""
706721"Using a generic class without specifying type parameters assumes :data:`Any` "
707722"for each position. In the following example, ``MyIterable`` is not generic "
708723"but implicitly inherits from ``Iterable[Any]``:"
709724msgstr ""
725+ "若使用泛型類別卻沒有特指型別參數,則會將每個位置視為 :data:`Any`。在下列的範"
726+ "例中 ``MyIterable`` 不是泛型,但隱性繼承了 ``Iterable[Any]``: ::"
710727
711728#: ../../library/typing.rst:608
712729msgid "User-defined generic type aliases are also supported. Examples::"
713- msgstr ""
730+ msgstr "使用者定義的泛型型別別名也有支援。例如: :: "
714731
715732#: ../../library/typing.rst:623
716733msgid ""
@@ -720,14 +737,16 @@ msgstr "為了向後相容性,泛型型別別名可以透過簡單的賦值來
720737
721738#: ../../library/typing.rst:632
722739msgid ":class:`Generic` no longer has a custom metaclass."
723- msgstr ""
740+ msgstr ":class:`Generic` 不再是一個自訂的 metaclass。 "
724741
725742#: ../../library/typing.rst:635
726743msgid ""
727744"Syntactic support for generics and type aliases is new in version 3.12. "
728745"Previously, generic classes had to explicitly inherit from :class:`Generic` "
729746"or contain a type variable in one of their bases."
730747msgstr ""
748+ "在版本 3.12 新增了泛型及型別別名的語法支援。在之前的版本中,泛型類別必須顯性"
749+ "繼承 :class:`Generic` 或是包含一個型別變數在基底類別 (base) 當中。"
731750
732751#: ../../library/typing.rst:640
733752msgid ""
@@ -738,12 +757,18 @@ msgid ""
738757"The one exception to this is that a list of types can be used to substitute "
739758"a :class:`ParamSpec`::"
740759msgstr ""
760+ "使用者定義的參數運算式 (parameter expression) 泛型一樣有支援,透過 ``[**P]`` "
761+ "格式的參數規格變數來進行表示。對於上述作為參數規格變數的型別變數,將持續被型"
762+ "別模組視為一個特定的型別變數。對此,其中一個例外是一個型別列表可以替代 :"
763+ "class:`ParamSpec`: ::"
741764
742765#: ../../library/typing.rst:651
743766msgid ""
744767"Classes generic over a :class:`ParamSpec` can also be created using explicit "
745768"inheritance from :class:`Generic`. In this case, ``**`` is not used::"
746769msgstr ""
770+ "具有 :class:`ParamSpec` 的泛型類別可以透過顯性繼承 :class:`Generic` 進行建"
771+ "立。在這種情況下,不需要使用 ``**``: ::"
747772
748773#: ../../library/typing.rst:661
749774msgid ""
@@ -753,19 +778,27 @@ msgid ""
753778"Type2, ...]`` for aesthetic reasons. Internally, the latter is converted to "
754779"the former, so the following are equivalent::"
755780msgstr ""
781+ "另外一個 :class:`TypeVar` 以及 :class:`ParamSpec` 之間的差異是,基於美觀因"
782+ "素,只有一個參數規格變數的泛型可以接受如 ``X[[Type1, Type2, ...]]`` 以及 "
783+ "``X[Type1, Type2, ...]`` 的參數列表。在內部中,後者會被轉換為前者,所以在下方"
784+ "的範例中為相等的: ::"
756785
757786#: ../../library/typing.rst:674
758787msgid ""
759788"Note that generics with :class:`ParamSpec` may not have correct "
760789"``__parameters__`` after substitution in some cases because they are "
761790"intended primarily for static type checking."
762791msgstr ""
792+ "請記得,具有 :class:`ParamSpec` 的泛型在某些情況下替換之後可能不會有正確的 "
793+ "``__parameters__``,因為參數規格主要還是用於靜態型別檢查。"
763794
764795#: ../../library/typing.rst:678
765796msgid ""
766797":class:`Generic` can now be parameterized over parameter expressions. See :"
767798"class:`ParamSpec` and :pep:`612` for more details."
768799msgstr ""
800+ ":class:`Generic` 現在可以透過參數運算式來進行參數化。詳細內容請見 :class:"
801+ "`ParamSpec` 以及 :pep:`612`。"
769802
770803#: ../../library/typing.rst:682
771804msgid ""
@@ -774,6 +807,9 @@ msgid ""
774807"parameterizing generics is cached, and most types in the typing module are :"
775808"term:`hashable` and comparable for equality."
776809msgstr ""
810+ "一個使用者定義的泛型類別可以將 ABC 作為他們的基底類別,且不會有 metaclass 衝"
811+ "突。泛型的 metaclass 則不支援。參數化泛型的輸出將被存為快取,而在型別模組中多"
812+ "數的型別皆為 :term:`hashable` 且可以比較相等性。"
777813
778814#: ../../library/typing.rst:689
779815msgid "The :data:`Any` type"
@@ -785,12 +821,16 @@ msgid ""
785821"every type as being compatible with :data:`Any` and :data:`Any` as being "
786822"compatible with every type."
787823msgstr ""
824+ ":data:`Any` 是一種特別的型別。一個靜態型別檢查器會將每個型別視為可相容於 :"
825+ "data:`Any` 且 :data:`Any` 也可以相容於每個型別。"
788826
789827#: ../../library/typing.rst:695
790828msgid ""
791829"This means that it is possible to perform any operation or method call on a "
792830"value of type :data:`Any` and assign it to any variable::"
793831msgstr ""
832+ "這意味著如果在一個為 :data:`Any` 的值上執行任何操作或呼叫方法是可行的,且可以"
833+ "賦值給任意變數: ::"
794834
795835#: ../../library/typing.rst:713
796836msgid ""
@@ -800,18 +840,23 @@ msgid ""
800840"declared to be of type :class:`str` and receives an :class:`int` value at "
801841"runtime!"
802842msgstr ""
843+ "請注意,當賦予型別為 :data:`Any` 的值更精確的型別時,將不會執行任何型別檢查。"
844+ "舉例來說,靜態型別檢查器不會在 runtime 中,將 ``a`` 賦值給 ``s`` 的情況下回報"
845+ "錯誤,儘管 ``s`` 是被宣告為型別 :class:`str` 卻接收到 :class:`int` 的值!"
803846
804847#: ../../library/typing.rst:719
805848msgid ""
806849"Furthermore, all functions without a return type or parameter types will "
807850"implicitly default to using :data:`Any`::"
808- msgstr ""
851+ msgstr "另外,所有缺少回傳型別或參數型別的函式將會隱性預設為 :data:`Any`: :: "
809852
810853#: ../../library/typing.rst:732
811854msgid ""
812855"This behavior allows :data:`Any` to be used as an *escape hatch* when you "
813856"need to mix dynamically and statically typed code."
814857msgstr ""
858+ "當你需要混和動態及靜態的型別程式碼,這個行為允許 :data:`Any` 被當作一個\\ *緊"
859+ "急出口 (escape hatch)*\\ 使用。"
815860
816861#: ../../library/typing.rst:735
817862msgid ""
@@ -820,6 +865,9 @@ msgid ""
820865"unlike :data:`Any`, the reverse is not true: :class:`object` is *not* a "
821866"subtype of every other type."
822867msgstr ""
868+ ":data:`Any` 的行為對比 :class:`object` 的行為。與 :data:`Any` 相似,所有的型"
869+ "別會作為 :class:`object` 的子型別。然而,不像 :data:`Any`,反之不亦然::"
870+ "class:`object` 並\\ *不是*\\ 一個其他型別的子型別。"
823871
824872#: ../../library/typing.rst:740
825873msgid ""
@@ -828,12 +876,17 @@ msgid ""
828876"it as a return value) of a more specialized type is a type error. For "
829877"example::"
830878msgstr ""
879+ "這意味著當一個值的型別為 :class:`object` 時,型別檢查器會拒絕幾乎所有的操作,"
880+ "並將賦予這個值到一個特定型別變數(或是當作回傳值使用)視為一個型別錯誤。舉例"
881+ "來說: ::"
831882
832883#: ../../library/typing.rst:762
833884msgid ""
834885"Use :class:`object` to indicate that a value could be any type in a typesafe "
835886"manner. Use :data:`Any` to indicate that a value is dynamically typed."
836887msgstr ""
888+ "使用 :class:`object` ,將指出在型別安全 (typesafe) 的習慣之下一個值可以為任意"
889+ "型別。使用 :data:`Any`,將指出這個值是個動態型別。"
837890
838891#: ../../library/typing.rst:767
839892msgid "Nominal vs structural subtyping"
@@ -1196,7 +1249,7 @@ msgstr ""
11961249
11971250#: ../../library/typing.rst:1166
11981251msgid ":class:`ParamSpec`"
1199- msgstr ":class:`ParamSpec`。 "
1252+ msgstr ":class:`ParamSpec`"
12001253
12011254#: ../../library/typing.rst:1167 ../../library/typing.rst:1929
12021255msgid ":ref:`annotating-callables`"
@@ -3613,7 +3666,7 @@ msgstr ":gh:`92332`"
36133666
36143667#: ../../library/typing.rst:3683
36153668msgid ":class:`typing.Hashable` and :class:`typing.Sized`"
3616- msgstr ":class:`typing.Hashable` 和 :class:`typing.Sized`。 "
3669+ msgstr ":class:`typing.Hashable` 和 :class:`typing.Sized`"
36173670
36183671#: ../../library/typing.rst:3684 ../../library/typing.rst:3688
36193672msgid "3.12"
0 commit comments