Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 6932221

Browse files
github-actions[bot]mattwang44
authored andcommittedMay 24, 2024
sync with cpython 122dd4f4
1 parent b719e97 commit 6932221

File tree

1 file changed

+96
-92
lines changed

1 file changed

+96
-92
lines changed
 

‎library/dataclasses.po

Lines changed: 96 additions & 92 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ msgid ""
44
msgstr ""
55
"Project-Id-Version: Python 3.12\n"
66
"Report-Msgid-Bugs-To: \n"
7-
"POT-Creation-Date: 2024-05-21 00:03+0000\n"
7+
"POT-Creation-Date: 2024-05-24 00:03+0000\n"
88
"PO-Revision-Date: 2023-02-11 15:02+0800\n"
99
"Last-Translator: \n"
1010
"Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-"
@@ -324,13 +324,17 @@ msgid ""
324324
"*slots*: If true (the default is ``False``), :attr:`~object.__slots__` "
325325
"attribute will be generated and new class will be returned instead of the "
326326
"original one. If :attr:`!__slots__` is already defined in the class, then :"
327-
"exc:`TypeError` is raised."
327+
"exc:`TypeError` is raised. Calling no-arg :func:`super` in dataclasses using "
328+
"``slots=True`` will result in the following exception being raised: "
329+
"``TypeError: super(type, obj): obj must be an instance or subtype of type``. "
330+
"The two-arg :func:`super` is a valid workaround. See :gh:`90562` for full "
331+
"details."
328332
msgstr ""
329333
"``slots``:如果為 true(預設為 ``False``),將生成 :attr:`~object.__slots__` "
330334
"屬性並回傳新類而不是原始類。如果 :attr:`!__slots__` 已經在類中定義,則 :exc:"
331335
"`TypeError` 被引發。"
332336

333-
#: ../../library/dataclasses.rst:192
337+
#: ../../library/dataclasses.rst:195
334338
#, fuzzy
335339
msgid ""
336340
"If a field name is already included in the :attr:`!__slots__` of a base "
@@ -346,7 +350,7 @@ msgstr ""
346350
"夠確定繼承的插槽,基底類別 :attr:`!__slots__` 可以是任何可疊代的,但*不是*疊"
347351
"代器。"
348352

349-
#: ../../library/dataclasses.rst:202
353+
#: ../../library/dataclasses.rst:205
350354
#, fuzzy
351355
msgid ""
352356
"*weakref_slot*: If true (the default is ``False``), add a slot named "
@@ -358,14 +362,14 @@ msgstr ""
358362
"插槽,這是使實例可弱引用所必需的。在沒有指定 ``slots=True`` 的情況下指定 "
359363
"``weakref_slot=True`` 是錯誤的。"
360364

361-
#: ../../library/dataclasses.rst:209
365+
#: ../../library/dataclasses.rst:212
362366
#, fuzzy
363367
msgid ""
364368
"``field``\\s may optionally specify a default value, using normal Python "
365369
"syntax::"
366370
msgstr "``field``\\s 可以選擇指定一個預設值,使用普通的 Python 語法: ::"
367371

368-
#: ../../library/dataclasses.rst:217
372+
#: ../../library/dataclasses.rst:220
369373
#, fuzzy
370374
msgid ""
371375
"In this example, both :attr:`!a` and :attr:`!b` will be included in the "
@@ -374,7 +378,7 @@ msgstr ""
374378
"在此示例中,:attr:`!a` 和 :attr:`!b` 都將包含在新增的 :meth:`~object."
375379
"__init__` 方法中,該方法將定義為: ::"
376380

377-
#: ../../library/dataclasses.rst:222
381+
#: ../../library/dataclasses.rst:225
378382
#, fuzzy
379383
msgid ""
380384
":exc:`TypeError` will be raised if a field without a default value follows a "
@@ -384,7 +388,7 @@ msgstr ""
384388
":exc:`TypeError` 如果沒有預設值的欄位跟在具有預設值的欄位之後,將引發。無論這"
385389
"發生在單個類中還是作為類繼承的結果,都是如此。"
386390

387-
#: ../../library/dataclasses.rst:228
391+
#: ../../library/dataclasses.rst:231
388392
#, fuzzy
389393
msgid ""
390394
"For common and simple use cases, no other functionality is required. There "
@@ -397,7 +401,7 @@ msgstr ""
397401
"位資訊。為了滿足這種對附加資訊的需求,你可以通過呼叫提供的 :func:`!field` 函"
398402
"式來替換預設欄位值。例如: ::"
399403

400-
#: ../../library/dataclasses.rst:241
404+
#: ../../library/dataclasses.rst:244
401405
#, fuzzy
402406
msgid ""
403407
"As shown above, the :const:`MISSING` value is a sentinel object used to "
@@ -409,11 +413,11 @@ msgstr ""
409413
"供。使用此標記是因為“None”對於某些具有不同含義的參數是有效值。任何程式碼都不"
410414
"應直接使用 :const:`MISSING` 值。"
411415

412-
#: ../../library/dataclasses.rst:246
416+
#: ../../library/dataclasses.rst:249
413417
msgid "The parameters to :func:`!field` are:"
414418
msgstr ":func:`!field` 的參數是:"
415419

416-
#: ../../library/dataclasses.rst:248
420+
#: ../../library/dataclasses.rst:251
417421
#, fuzzy
418422
msgid ""
419423
"*default*: If provided, this will be the default value for this field. This "
@@ -423,7 +427,7 @@ msgstr ""
423427
"*default*:如果提供,這將是該欄位的預設值。這是必需的,因為 :meth:`!field` 呼"
424428
"叫本身會替換預設值的正常位置。"
425429

426-
#: ../../library/dataclasses.rst:252
430+
#: ../../library/dataclasses.rst:255
427431
#, fuzzy
428432
msgid ""
429433
"*default_factory*: If provided, it must be a zero-argument callable that "
@@ -436,7 +440,7 @@ msgstr ""
436440
"時將被呼叫。除其他用途外,這可用於指定具有可變預設值的欄位,如下所述。同時指"
437441
"定 *default* 和 *default_factory* 是錯誤的。"
438442

439-
#: ../../library/dataclasses.rst:258
443+
#: ../../library/dataclasses.rst:261
440444
#, fuzzy
441445
msgid ""
442446
"*init*: If true (the default), this field is included as a parameter to the "
@@ -445,7 +449,7 @@ msgstr ""
445449
"*init*:如果為 true(預設值),則此欄位將作為生成的 :meth:`~object.__init__` "
446450
"方法的參數包含在內。"
447451

448-
#: ../../library/dataclasses.rst:261
452+
#: ../../library/dataclasses.rst:264
449453
#, fuzzy
450454
msgid ""
451455
"*repr*: If true (the default), this field is included in the string returned "
@@ -454,7 +458,7 @@ msgstr ""
454458
"*repr*:如果為真(預設值),則此欄位包含在生成的 :meth:`~object.__repr__` 方"
455459
"法回傳的字串中。"
456460

457-
#: ../../library/dataclasses.rst:264
461+
#: ../../library/dataclasses.rst:267
458462
#, fuzzy
459463
msgid ""
460464
"*hash*: This can be a bool or ``None``. If true, this field is included in "
@@ -468,7 +472,7 @@ msgstr ""
468472
"如果一個欄位用於比較,則應在雜湊中考慮該欄位。不鼓勵將此值設定為“無”以外的任"
469473
"何值。"
470474

471-
#: ../../library/dataclasses.rst:271
475+
#: ../../library/dataclasses.rst:274
472476
#, fuzzy
473477
msgid ""
474478
"One possible reason to set ``hash=False`` but ``compare=True`` would be if a "
@@ -481,7 +485,7 @@ msgstr ""
481485
"湊值的成本很高,則需要該欄位進行相等性測試,並且還有其他欄位有助於型別的雜湊"
482486
"值。即使一個欄位被排除在雜湊之外,它仍然會被用於比較。"
483487

484-
#: ../../library/dataclasses.rst:277
488+
#: ../../library/dataclasses.rst:280
485489
#, fuzzy
486490
msgid ""
487491
"*compare*: If true (the default), this field is included in the generated "
@@ -491,7 +495,7 @@ msgstr ""
491495
"*compare*:如果為真(預設值),則此欄位包含在生成的相等和比較方法中(:meth:"
492496
"`~object.__eq__`、:meth:`~object.__gt__` 等)。"
493497

494-
#: ../../library/dataclasses.rst:281
498+
#: ../../library/dataclasses.rst:284
495499
#, fuzzy
496500
msgid ""
497501
"*metadata*: This can be a mapping or ``None``. ``None`` is treated as an "
@@ -506,7 +510,7 @@ msgstr ""
506510
"不被資料類別使用,而是作為第三方擴充機制提供的。多個第三方可以各自擁有自己的"
507511
"密鑰,用作元資料中的命名空間。"
508512

509-
#: ../../library/dataclasses.rst:289
513+
#: ../../library/dataclasses.rst:292
510514
#, fuzzy
511515
msgid ""
512516
"*kw_only*: If true, this field will be marked as keyword-only. This is used "
@@ -515,7 +519,7 @@ msgstr ""
515519
"*kw_only*:如果為真,該欄位將被標記為僅限關鍵字。這在計算生成的 :meth:"
516520
"`~object.__init__` 方法的參數時使用。"
517521

518-
#: ../../library/dataclasses.rst:295
522+
#: ../../library/dataclasses.rst:298
519523
#, fuzzy
520524
msgid ""
521525
"If the default value of a field is specified by a call to :func:`!field`, "
@@ -531,7 +535,7 @@ msgstr ""
531535
"在 :func:`@dataclass <dataclass>` 裝飾器運行後,類別屬性將全部包含欄位的預設"
532536
"值,就像預設值本身已指定一樣。例如,在: ::"
533537

534-
#: ../../library/dataclasses.rst:311
538+
#: ../../library/dataclasses.rst:314
535539
#, fuzzy
536540
msgid ""
537541
"The class attribute :attr:`!C.z` will be ``10``, the class attribute :attr:`!"
@@ -541,7 +545,7 @@ msgstr ""
541545
"類別屬性 :attr:`!C.z` 將為 ``10``,類別屬性 :attr:`!C.t` 將為 ``20``,類別屬"
542546
"性 :attr:`!C.x` 和 :attr:`!C.y` 將不會放。"
543547

544-
#: ../../library/dataclasses.rst:317
548+
#: ../../library/dataclasses.rst:320
545549
#, fuzzy
546550
msgid ""
547551
":class:`!Field` objects describe each defined field. These objects are "
@@ -553,15 +557,15 @@ msgstr ""
553557
"`fields` 模組級方法回傳(見下文)。使用者不應該直接實例化 :class:`!Field` 物"
554558
"件。它記錄的屬性是:"
555559

556-
#: ../../library/dataclasses.rst:322
560+
#: ../../library/dataclasses.rst:325
557561
msgid ":attr:`!name`: The name of the field."
558562
msgstr ":attr:`!name`:欄位的名稱。"
559563

560-
#: ../../library/dataclasses.rst:323
564+
#: ../../library/dataclasses.rst:326
561565
msgid ":attr:`!type`: The type of the field."
562566
msgstr ":attr:`!type`:欄位的型別。"
563567

564-
#: ../../library/dataclasses.rst:324
568+
#: ../../library/dataclasses.rst:327
565569
#, fuzzy
566570
msgid ""
567571
":attr:`!default`, :attr:`!default_factory`, :attr:`!init`, :attr:`!repr`, :"
@@ -572,14 +576,14 @@ msgstr ""
572576
"attr:`!hash`、:attr:`!compare`, :attr:`!metadata` 和 :attr:`!kw_only` 有與它"
573577
"們在 :func:`field` 函式中的含義和值相同。"
574578

575-
#: ../../library/dataclasses.rst:328
579+
#: ../../library/dataclasses.rst:331
576580
#, fuzzy
577581
msgid ""
578582
"Other attributes may exist, but they are private and must not be inspected "
579583
"or relied on."
580584
msgstr "可能存在其他屬性,但它們是私有的,不得檢查或依賴。"
581585

582-
#: ../../library/dataclasses.rst:333
586+
#: ../../library/dataclasses.rst:336
583587
#, fuzzy
584588
msgid ""
585589
"Returns a tuple of :class:`Field` objects that define the fields for this "
@@ -591,7 +595,7 @@ msgstr ""
591595
"實例。如果未傳遞資料類別或其中一個實例,則引發 :exc:`TypeError`。不回傳 "
592596
"``ClassVar`` 或 ``InitVar`` 的偽欄位。"
593597

594-
#: ../../library/dataclasses.rst:340
598+
#: ../../library/dataclasses.rst:343
595599
#, fuzzy
596600
msgid ""
597601
"Converts the dataclass *obj* to a dict (by using the factory function "
@@ -603,23 +607,23 @@ msgstr ""
603607
"都被轉換為其欄位的字典,作為 ``name: value`` 對。資料類別、字典、列表和元組被"
604608
"遞迴到。其他物件使用 :func:`copy.deepcopy` 複製。"
605609

606-
#: ../../library/dataclasses.rst:346
610+
#: ../../library/dataclasses.rst:349
607611
#, fuzzy
608612
msgid "Example of using :func:`!asdict` on nested dataclasses::"
609613
msgstr "在嵌套資料類別上使用 :func:`!asdict` 的範例: ::"
610614

611-
#: ../../library/dataclasses.rst:363 ../../library/dataclasses.rst:383
615+
#: ../../library/dataclasses.rst:366 ../../library/dataclasses.rst:386
612616
#, fuzzy
613617
msgid "To create a shallow copy, the following workaround may be used::"
614618
msgstr "要建立淺複製,可以使用以下解決方法:"
615619

616-
#: ../../library/dataclasses.rst:367
620+
#: ../../library/dataclasses.rst:370
617621
#, fuzzy
618622
msgid ""
619623
":func:`!asdict` raises :exc:`TypeError` if *obj* is not a dataclass instance."
620624
msgstr ":func:`!asdict` 如果 *obj* 不是資料類別實例,則引發 :exc:`TypeError`。"
621625

622-
#: ../../library/dataclasses.rst:372
626+
#: ../../library/dataclasses.rst:375
623627
#, fuzzy
624628
msgid ""
625629
"Converts the dataclass *obj* to a tuple (by using the factory function "
@@ -631,19 +635,19 @@ msgstr ""
631635
"都被轉換為其欄位值的元組。資料類別、字典、列表和元組被遞迴到。其他物件使用 :"
632636
"func:`copy.deepcopy` 複製。"
633637

634-
#: ../../library/dataclasses.rst:378
638+
#: ../../library/dataclasses.rst:381
635639
msgid "Continuing from the previous example::"
636640
msgstr "從前面的例子繼續: ::"
637641

638-
#: ../../library/dataclasses.rst:387
642+
#: ../../library/dataclasses.rst:390
639643
#, fuzzy
640644
msgid ""
641645
":func:`!astuple` raises :exc:`TypeError` if *obj* is not a dataclass "
642646
"instance."
643647
msgstr ""
644648
":func:`!astuple` 如果 *obj* 不是資料類別實例,則引發 :exc:`TypeError`。"
645649

646-
#: ../../library/dataclasses.rst:392
650+
#: ../../library/dataclasses.rst:395
647651
#, fuzzy
648652
msgid ""
649653
"Creates a new dataclass with name *cls_name*, fields as defined in *fields*, "
@@ -663,13 +667,13 @@ msgstr ""
663667
"``kw_only`` 的值, ``slots`` 和 ``weakref_slot`` 與它們在 :func:`dataclass` 中"
664668
"的含義相同。"
665669

666-
#: ../../library/dataclasses.rst:402
670+
#: ../../library/dataclasses.rst:405
667671
msgid ""
668672
"If *module* is defined, the :attr:`!__module__` attribute of the dataclass "
669673
"is set to that value. By default, it is set to the module name of the caller."
670674
msgstr ""
671675

672-
#: ../../library/dataclasses.rst:406
676+
#: ../../library/dataclasses.rst:409
673677
#, fuzzy
674678
msgid ""
675679
"This function is not strictly required, because any Python mechanism for "
@@ -681,11 +685,11 @@ msgstr ""
681685
"制都可以應用 :func:`dataclass` 函式將該類轉換為資料類別。提供此功能是為了方"
682686
"便。例如: ::"
683687

684-
#: ../../library/dataclasses.rst:418
688+
#: ../../library/dataclasses.rst:421
685689
msgid "Is equivalent to::"
686690
msgstr "相當於: ::"
687691

688-
#: ../../library/dataclasses.rst:431
692+
#: ../../library/dataclasses.rst:434
689693
#, fuzzy
690694
msgid ""
691695
"Creates a new object of the same type as *obj*, replacing fields with values "
@@ -697,7 +701,7 @@ msgstr ""
697701
"``obj`` 不是資料類別,則引發 :exc:`TypeError`。如果 ``changes`` 中的值未指定"
698702
"欄位,則引發 :exc:`TypeError`。"
699703

700-
#: ../../library/dataclasses.rst:436
704+
#: ../../library/dataclasses.rst:439
701705
#, fuzzy
702706
msgid ""
703707
"The newly returned object is created by calling the :meth:`~object.__init__` "
@@ -707,7 +711,7 @@ msgstr ""
707711
"新回傳的對像是通過呼叫資料類別的 :meth:`~object.__init__` 方法建立的。這確"
708712
"保 :meth:`__post_init__`(如果存在)也被呼叫。"
709713

710-
#: ../../library/dataclasses.rst:440
714+
#: ../../library/dataclasses.rst:443
711715
#, fuzzy
712716
msgid ""
713717
"Init-only variables without default values, if any exist, must be specified "
@@ -717,7 +721,7 @@ msgstr ""
717721
"沒有預設值的僅初始化變數(如果存在)必須在呼叫 :func:`replace` 時指定,以便它"
718722
"們可以傳遞給 :meth:`__init__` 和 :meth:`__post_init__`。"
719723

720-
#: ../../library/dataclasses.rst:444
724+
#: ../../library/dataclasses.rst:447
721725
#, fuzzy
722726
msgid ""
723727
"It is an error for *changes* to contain any fields that are defined as "
@@ -726,7 +730,7 @@ msgstr ""
726730
"*changes* 包含任何定義為具有 ``init=False`` 的欄位是錯誤的。在這種情況下將引"
727731
"發 :exc:`ValueError`。"
728732

729-
#: ../../library/dataclasses.rst:448
733+
#: ../../library/dataclasses.rst:451
730734
#, fuzzy
731735
msgid ""
732736
"Be forewarned about how ``init=False`` fields work during a call to :func:`!"
@@ -743,15 +747,15 @@ msgstr ""
743747
"造函式可能是明智的,或者可能是處理實例複製的自定義:func:`!replace` (或類似命"
744748
"名的)方法。"
745749

746-
#: ../../library/dataclasses.rst:459
750+
#: ../../library/dataclasses.rst:462
747751
#, fuzzy
748752
msgid ""
749753
"Return ``True`` if its parameter is a dataclass or an instance of one, "
750754
"otherwise return ``False``."
751755
msgstr ""
752756
"如果它的參數是一個資料類別或一個實例,則回傳 ``True``,否則回傳 ``False``。"
753757

754-
#: ../../library/dataclasses.rst:462
758+
#: ../../library/dataclasses.rst:465
755759
#, fuzzy
756760
msgid ""
757761
"If you need to know if a class is an instance of a dataclass (and not a "
@@ -761,12 +765,12 @@ msgstr ""
761765
"如果你需要知道一個類是否是資料類別的實例(而不是資料類別本身),那麼新增一個"
762766
"進一步的檢查 ``not isinstance(obj, type)``: ::"
763767

764-
#: ../../library/dataclasses.rst:471
768+
#: ../../library/dataclasses.rst:474
765769
#, fuzzy
766770
msgid "A sentinel value signifying a missing default or default_factory."
767771
msgstr "表示缺少 default 或 default_factory 的標記值。"
768772

769-
#: ../../library/dataclasses.rst:475
773+
#: ../../library/dataclasses.rst:478
770774
#, fuzzy
771775
msgid ""
772776
"A sentinel value used as a type annotation. Any fields after a pseudo-field "
@@ -782,21 +786,21 @@ msgstr ""
782786
"類欄位的名稱。按照慣例,名稱 ``_`` 用於 :const:`!KW_ONLY` 欄位。僅關鍵字欄位"
783787
"表示 :meth:`~object.__init__` 參數,在實例化類時必須將其指定為關鍵字。"
784788

785-
#: ../../library/dataclasses.rst:484
789+
#: ../../library/dataclasses.rst:487
786790
#, fuzzy
787791
msgid ""
788792
"In this example, the fields ``y`` and ``z`` will be marked as keyword-only "
789793
"fields::"
790794
msgstr "在此示例中,欄位 ``y`` 和 ``z`` 將被標記為僅關鍵字欄位: ::"
791795

792-
#: ../../library/dataclasses.rst:495
796+
#: ../../library/dataclasses.rst:498
793797
#, fuzzy
794798
msgid ""
795799
"In a single dataclass, it is an error to specify more than one field whose "
796800
"type is :const:`!KW_ONLY`."
797801
msgstr "在單個資料類別中,指定多個型別為 :const:`!KW_ONLY` 的欄位是錯誤的。"
798802

799-
#: ../../library/dataclasses.rst:502
803+
#: ../../library/dataclasses.rst:505
800804
#, fuzzy
801805
msgid ""
802806
"Raised when an implicitly defined :meth:`~object.__setattr__` or :meth:"
@@ -806,12 +810,12 @@ msgstr ""
806810
"當在使用 frozen=True 定義的資料類別上呼叫隱式定義的 :meth:`__setattr__` 或 :"
807811
"meth:`__delattr__` 時引發。它是 :exc:`AttributeError` 的子類別。"
808812

809-
#: ../../library/dataclasses.rst:509
813+
#: ../../library/dataclasses.rst:512
810814
#, fuzzy
811815
msgid "Post-init processing"
812816
msgstr "初始化後處理"
813817

814-
#: ../../library/dataclasses.rst:513
818+
#: ../../library/dataclasses.rst:516
815819
#, fuzzy
816820
msgid ""
817821
"When defined on the class, it will be called by the generated :meth:`~object."
@@ -827,14 +831,14 @@ msgstr ""
827831
"按照它們在類中定義的順序傳遞給 :meth:`!__post_init__` 。如果沒有生成 :meth:`!"
828832
"__init__` 方法,那麼 :meth:`!__post_init__` 將不會被自動呼叫。"
829833

830-
#: ../../library/dataclasses.rst:520
834+
#: ../../library/dataclasses.rst:523
831835
#, fuzzy
832836
msgid ""
833837
"Among other uses, this allows for initializing field values that depend on "
834838
"one or more other fields. For example::"
835839
msgstr "在其他用途中,這允許初始化依賴於一個或多個其他欄位的欄位值。例如: ::"
836840

837-
#: ../../library/dataclasses.rst:532
841+
#: ../../library/dataclasses.rst:535
838842
#, fuzzy
839843
msgid ""
840844
"The :meth:`~object.__init__` method generated by :func:`@dataclass "
@@ -846,7 +850,7 @@ msgstr ""
846850
"類別 :meth:`!__init__` 方法。如果基底類別有一個必須呼叫的 :meth:`!__init__` "
847851
"方法,通常在 :meth:`__post_init__` 方法中呼叫此方法: ::"
848852

849-
#: ../../library/dataclasses.rst:549
853+
#: ../../library/dataclasses.rst:552
850854
#, fuzzy
851855
msgid ""
852856
"Note, however, that in general the dataclass-generated :meth:`!__init__` "
@@ -856,7 +860,7 @@ msgstr ""
856860
"但是請注意,通常不需要呼叫資料類別生成的 :meth:`!__init__` 方法,因為派生資料"
857861
"類別將負責初始化作為資料類別本身的任何基底類別的所有欄位。"
858862

859-
#: ../../library/dataclasses.rst:553
863+
#: ../../library/dataclasses.rst:556
860864
#, fuzzy
861865
msgid ""
862866
"See the section below on init-only variables for ways to pass parameters to :"
@@ -866,11 +870,11 @@ msgstr ""
866870
"請參閱下面有關僅初始化變數的部分,了解將參數傳遞給 :meth:`!__post_init__` 的"
867871
"方法。另請參閱有關 :func:`replace` 如何處理 ``init=False`` 欄位的警告。"
868872

869-
#: ../../library/dataclasses.rst:560
873+
#: ../../library/dataclasses.rst:563
870874
msgid "Class variables"
871875
msgstr "類別變數"
872876

873-
#: ../../library/dataclasses.rst:562
877+
#: ../../library/dataclasses.rst:565
874878
#, fuzzy
875879
msgid ""
876880
"One of the few places where :func:`@dataclass <dataclass>` actually inspects "
@@ -887,12 +891,12 @@ msgstr ""
887891
"外,並被資料類別機制忽略。模組級 :func:`fields` 函式不會回傳此類別 "
888892
"``ClassVar`` 偽欄位。"
889893

890-
#: ../../library/dataclasses.rst:573
894+
#: ../../library/dataclasses.rst:576
891895
#, fuzzy
892896
msgid "Init-only variables"
893897
msgstr "僅初始化變數"
894898

895-
#: ../../library/dataclasses.rst:575
899+
#: ../../library/dataclasses.rst:578
896900
#, fuzzy
897901
msgid ""
898902
"Another place where :func:`@dataclass <dataclass>` inspects a type "
@@ -912,14 +916,14 @@ msgstr ""
912916
"的 :meth:`~object.__init__` 方法,並傳遞給可選的 :meth:`__post_init__` 方法。"
913917
"它們不被資料類使用。"
914918

915-
#: ../../library/dataclasses.rst:585
919+
#: ../../library/dataclasses.rst:588
916920
#, fuzzy
917921
msgid ""
918922
"For example, suppose a field will be initialized from a database, if a value "
919923
"is not provided when creating the class::"
920924
msgstr "例如,假設一個欄位將從資料庫中初始化,如果在建立類時沒有提供值: ::"
921925

922-
#: ../../library/dataclasses.rst:600
926+
#: ../../library/dataclasses.rst:603
923927
#, fuzzy
924928
msgid ""
925929
"In this case, :func:`fields` will return :class:`Field` objects for :attr:`!"
@@ -928,11 +932,11 @@ msgstr ""
928932
"在這種情況下,:func:`fields` 將為 :attr:`!i` 和 :attr:`!j` 回傳 :class:"
929933
"`Field` 物件,但不會為 :attr:`!database` 回傳。"
930934

931-
#: ../../library/dataclasses.rst:606
935+
#: ../../library/dataclasses.rst:609
932936
msgid "Frozen instances"
933937
msgstr "凍結實例"
934938

935-
#: ../../library/dataclasses.rst:608
939+
#: ../../library/dataclasses.rst:611
936940
#, fuzzy
937941
msgid ""
938942
"It is not possible to create truly immutable Python objects. However, by "
@@ -946,7 +950,7 @@ msgstr ""
946950
"別將向類新增 :meth:`~object.__setattr__` 和 :meth:`~object.__delattr__` 方"
947951
"法。這些方法在呼叫時會引發 :exc:`FrozenInstanceError`。"
948952

949-
#: ../../library/dataclasses.rst:614
953+
#: ../../library/dataclasses.rst:617
950954
#, fuzzy
951955
msgid ""
952956
"There is a tiny performance penalty when using ``frozen=True``: :meth:"
@@ -956,11 +960,11 @@ msgstr ""
956960
"使用 ``frozen=True`` 時有一個微小的性能損失::meth:`~object.__init__` 不能使"
957961
"用簡單賦值來初始化欄位,必須使用 :meth:`!object.__setattr__`。"
958962

959-
#: ../../library/dataclasses.rst:623
963+
#: ../../library/dataclasses.rst:626
960964
msgid "Inheritance"
961965
msgstr "繼承"
962966

963-
#: ../../library/dataclasses.rst:625
967+
#: ../../library/dataclasses.rst:628
964968
#, fuzzy
965969
msgid ""
966970
"When the dataclass is being created by the :func:`@dataclass <dataclass>` "
@@ -978,7 +982,7 @@ msgstr ""
978982
"將自己的欄位新增到有序映射中。所有生成的方法都將使用這種組合的、計算的有序欄"
979983
"位映射。因為欄位是按插入順序排列的,所以派生類會覆蓋基底類別。一個例子: ::"
980984

981-
#: ../../library/dataclasses.rst:645
985+
#: ../../library/dataclasses.rst:648
982986
#, fuzzy
983987
msgid ""
984988
"The final list of fields is, in order, :attr:`!x`, :attr:`!y`, :attr:`!z`. "
@@ -988,19 +992,19 @@ msgstr ""
988992
"最終的欄位列表按順序為 :attr:`!x`、:attr:`!y`、:attr:`!z`。:attr:`!x` 的最終"
989993
"型別是 :class:`int`,如類別 :class:`!C` 中指定的那樣。"
990994

991-
#: ../../library/dataclasses.rst:648
995+
#: ../../library/dataclasses.rst:651
992996
#, fuzzy
993997
msgid ""
994998
"The generated :meth:`~object.__init__` method for :class:`!C` will look "
995999
"like::"
9961000
msgstr "為 :class:`!C` 生成的 :meth:`~object.__init__` 方法將如下所示: ::"
9971001

998-
#: ../../library/dataclasses.rst:653
1002+
#: ../../library/dataclasses.rst:656
9991003
#, fuzzy
10001004
msgid "Re-ordering of keyword-only parameters in :meth:`!__init__`"
10011005
msgstr ":meth:`!__init__` 中僅關鍵字參數的重新排序"
10021006

1003-
#: ../../library/dataclasses.rst:655
1007+
#: ../../library/dataclasses.rst:658
10041008
#, fuzzy
10051009
msgid ""
10061010
"After the parameters needed for :meth:`~object.__init__` are computed, any "
@@ -1012,7 +1016,7 @@ msgstr ""
10121016
"僅關鍵字)參數之後。這是如何在 Python 中實作僅關鍵字參數的要求:它們必須位於"
10131017
"非僅關鍵字參數之後。"
10141018

1015-
#: ../../library/dataclasses.rst:661
1019+
#: ../../library/dataclasses.rst:664
10161020
#, fuzzy
10171021
msgid ""
10181022
"In this example, :attr:`!Base.y`, :attr:`!Base.w`, and :attr:`!D.t` are "
@@ -1022,12 +1026,12 @@ msgstr ""
10221026
"在此示例中,:attr:`!Base.y`、:attr:`!Base.w` 和 :attr:`!D.t` 是僅限關鍵字的欄"
10231027
"位,:attr:`!Base.x` 和 :attr:`!D.z` 是常規欄位: ::"
10241028

1025-
#: ../../library/dataclasses.rst:676
1029+
#: ../../library/dataclasses.rst:679
10261030
#, fuzzy
10271031
msgid "The generated :meth:`!__init__` method for :class:`!D` will look like::"
10281032
msgstr "為 :class:`!D` 生成的 :meth:`!__init__` 方法將如下所示: ::"
10291033

1030-
#: ../../library/dataclasses.rst:680
1034+
#: ../../library/dataclasses.rst:683
10311035
#, fuzzy
10321036
msgid ""
10331037
"Note that the parameters have been re-ordered from how they appear in the "
@@ -1037,18 +1041,18 @@ msgstr ""
10371041
"請注意,參數已根據它們在欄位列表中的顯示方式重新排序:從常規欄位派生的參數後"
10381042
"跟從僅關鍵字欄位派生的參數。"
10391043

1040-
#: ../../library/dataclasses.rst:684
1044+
#: ../../library/dataclasses.rst:687
10411045
#, fuzzy
10421046
msgid ""
10431047
"The relative ordering of keyword-only parameters is maintained in the re-"
10441048
"ordered :meth:`!__init__` parameter list."
10451049
msgstr "僅關鍵字參數的相對順序在重新排序的 :meth:`!__init__` 參數列表中維護。"
10461050

1047-
#: ../../library/dataclasses.rst:689
1051+
#: ../../library/dataclasses.rst:692
10481052
msgid "Default factory functions"
10491053
msgstr "預設工廠函式"
10501054

1051-
#: ../../library/dataclasses.rst:691
1055+
#: ../../library/dataclasses.rst:694
10521056
#, fuzzy
10531057
msgid ""
10541058
"If a :func:`field` specifies a *default_factory*, it is called with zero "
@@ -1058,7 +1062,7 @@ msgstr ""
10581062
"如果 :func:`field` 指定了 *default_factory*,當需要該欄位的預設值時,它會以零"
10591063
"引數呼叫。例如,要建立列表的新實例,請使用: ::"
10601064

1061-
#: ../../library/dataclasses.rst:697
1065+
#: ../../library/dataclasses.rst:700
10621066
#, fuzzy
10631067
msgid ""
10641068
"If a field is excluded from :meth:`~object.__init__` (using ``init=False``) "
@@ -1071,19 +1075,19 @@ msgstr ""
10711075
"位還指定了 ``default_factory``,那麼預設工廠函式將始終從生成的 :meth:"
10721076
"`__init__ 中呼叫`功能。發生這種情況是因為沒有其他方法可以為該欄位賦予初始值。"
10731077

1074-
#: ../../library/dataclasses.rst:704
1078+
#: ../../library/dataclasses.rst:707
10751079
msgid "Mutable default values"
10761080
msgstr "可變預設值"
10771081

1078-
#: ../../library/dataclasses.rst:706
1082+
#: ../../library/dataclasses.rst:709
10791083
#, fuzzy
10801084
msgid ""
10811085
"Python stores default member variable values in class attributes. Consider "
10821086
"this example, not using dataclasses::"
10831087
msgstr ""
10841088
"Python 將預設成員變數值存儲在類別屬性中。考慮這個例子,不使用資料類別: ::"
10851089

1086-
#: ../../library/dataclasses.rst:721
1090+
#: ../../library/dataclasses.rst:724
10871091
#, fuzzy
10881092
msgid ""
10891093
"Note that the two instances of class :class:`!C` share the same class "
@@ -1092,16 +1096,16 @@ msgstr ""
10921096
"請注意,類別 :class:`!C` 的兩個實例共享同一個類別變數 :attr:`!x`,正如預期的"
10931097
"那樣。"
10941098

1095-
#: ../../library/dataclasses.rst:724
1099+
#: ../../library/dataclasses.rst:727
10961100
#, fuzzy
10971101
msgid "Using dataclasses, *if* this code was valid::"
10981102
msgstr "使用資料類別,*如果*此程式碼有效: ::"
10991103

1100-
#: ../../library/dataclasses.rst:732
1104+
#: ../../library/dataclasses.rst:735
11011105
msgid "it would generate code similar to::"
11021106
msgstr "它會生成類似的程式碼: ::"
11031107

1104-
#: ../../library/dataclasses.rst:743
1108+
#: ../../library/dataclasses.rst:746
11051109
#, fuzzy
11061110
msgid ""
11071111
"This has the same issue as the original example using class :class:`!C`. "
@@ -1121,14 +1125,14 @@ msgstr ""
11211125
"到不可散列的預設參數,它將引發 :exc:`TypeError`。假設是如果一個值是不可散列"
11221126
"的,那麼它就是可變的。這是一個部分解決方案,但它確實可以防止許多常見錯誤。"
11231127

1124-
#: ../../library/dataclasses.rst:754
1128+
#: ../../library/dataclasses.rst:757
11251129
#, fuzzy
11261130
msgid ""
11271131
"Using default factory functions is a way to create new instances of mutable "
11281132
"types as default values for fields::"
11291133
msgstr "使用預設工廠函式是一種建立可變型別的新實例作為欄位預設值的方法: ::"
11301134

1131-
#: ../../library/dataclasses.rst:763
1135+
#: ../../library/dataclasses.rst:766
11321136
#, fuzzy
11331137
msgid ""
11341138
"Instead of looking for and disallowing objects of type :class:`list`, :class:"
@@ -1138,20 +1142,20 @@ msgstr ""
11381142
"不再查找和禁止型別為 :class:`list`、:class:`dict` 或 :class:`set` 的物件,現"
11391143
"在不允許使用不可散列的對像作為預設值。不可散列性用於近似可變性。"
11401144

1141-
#: ../../library/dataclasses.rst:770
1145+
#: ../../library/dataclasses.rst:773
11421146
#, fuzzy
11431147
msgid "Descriptor-typed fields"
11441148
msgstr "描述器型別的欄位"
11451149

1146-
#: ../../library/dataclasses.rst:772
1150+
#: ../../library/dataclasses.rst:775
11471151
#, fuzzy
11481152
msgid ""
11491153
"Fields that are assigned :ref:`descriptor objects <descriptors>` as their "
11501154
"default value have the following special behaviors:"
11511155
msgstr ""
11521156
"指定為\\ :ref:`描述器物件 <descriptors>`\\ 作為預設值的欄位具有以下特殊行為:"
11531157

1154-
#: ../../library/dataclasses.rst:775
1158+
#: ../../library/dataclasses.rst:778
11551159
#, fuzzy
11561160
msgid ""
11571161
"The value for the field passed to the dataclass's :meth:`~object.__init__` "
@@ -1161,7 +1165,7 @@ msgstr ""
11611165
"傳遞給資料類別的 :meth:`~object.__init__` 方法的欄位值被傳遞給描述器的 :meth:"
11621166
"`~object.__set__` 方法,而不是覆蓋描述器物件。"
11631167

1164-
#: ../../library/dataclasses.rst:779
1168+
#: ../../library/dataclasses.rst:782
11651169
#, fuzzy
11661170
msgid ""
11671171
"Similarly, when getting or setting the field, the descriptor's :meth:"
@@ -1171,7 +1175,7 @@ msgstr ""
11711175
"同樣,在獲取或設定欄位時,將呼叫描述器的 :meth:`~object.__get__` 或 :meth:`!"
11721176
"__set__` 方法,而不是回傳或覆蓋描述器物件。"
11731177

1174-
#: ../../library/dataclasses.rst:783
1178+
#: ../../library/dataclasses.rst:786
11751179
#, fuzzy
11761180
msgid ""
11771181
"To determine whether a field contains a default value, :func:`@dataclass "
@@ -1187,7 +1191,7 @@ msgstr ""
11871191
"面,如果描述器在這種情況下引發 :exc:`AttributeError`,則不會為該欄位提供預設"
11881192
"值。"
11891193

1190-
#: ../../library/dataclasses.rst:818
1194+
#: ../../library/dataclasses.rst:821
11911195
#, fuzzy
11921196
msgid ""
11931197
"Note that if a field is annotated with a descriptor type, but is not "

0 commit comments

Comments
 (0)
Please sign in to comment.