5
5
msgstr ""
6
6
"Project-Id-Version : Python 3.10\n "
7
7
"Report-Msgid-Bugs-To : \n "
8
- "POT-Creation-Date : 2022-01-09 00:10+0000\n "
8
+ "POT-Creation-Date : 2022-02-10 00:10+0000\n "
9
9
"PO-Revision-Date : 2018-07-15 18:56+0800\n "
10
10
"Last-Translator : \n "
11
11
"Language-Team : Chinese - TAIWAN (https://github.com/python/python-docs-zh- "
@@ -537,18 +537,18 @@ msgid ""
537
537
"type is :const:`KW_ONLY`."
538
538
msgstr ""
539
539
540
- #: ../../library/dataclasses.rst:480
540
+ #: ../../library/dataclasses.rst:482
541
541
msgid ""
542
542
"Raised when an implicitly defined :meth:`__setattr__` or :meth:`__delattr__` "
543
543
"is called on a dataclass which was defined with ``frozen=True``. It is a "
544
544
"subclass of :exc:`AttributeError`."
545
545
msgstr ""
546
546
547
- #: ../../library/dataclasses.rst:485
547
+ #: ../../library/dataclasses.rst:487
548
548
msgid "Post-init processing"
549
549
msgstr ""
550
550
551
- #: ../../library/dataclasses.rst:487
551
+ #: ../../library/dataclasses.rst:489
552
552
msgid ""
553
553
"The generated :meth:`__init__` code will call a method named :meth:"
554
554
"`__post_init__`, if :meth:`__post_init__` is defined on the class. It will "
@@ -558,39 +558,39 @@ msgid ""
558
558
"generated, then :meth:`__post_init__` will not automatically be called."
559
559
msgstr ""
560
560
561
- #: ../../library/dataclasses.rst:495
561
+ #: ../../library/dataclasses.rst:497
562
562
msgid ""
563
563
"Among other uses, this allows for initializing field values that depend on "
564
564
"one or more other fields. For example::"
565
565
msgstr ""
566
566
567
- #: ../../library/dataclasses.rst:507
567
+ #: ../../library/dataclasses.rst:509
568
568
msgid ""
569
569
"The :meth:`__init__` method generated by :func:`dataclass` does not call "
570
570
"base class :meth:`__init__` methods. If the base class has an :meth:"
571
571
"`__init__` method that has to be called, it is common to call this method in "
572
572
"a :meth:`__post_init__` method::"
573
573
msgstr ""
574
574
575
- #: ../../library/dataclasses.rst:524
575
+ #: ../../library/dataclasses.rst:526
576
576
msgid ""
577
577
"Note, however, that in general the dataclass-generated :meth:`__init__` "
578
578
"methods don't need to be called, since the derived dataclass will take care "
579
579
"of initializing all fields of any base class that is a dataclass itself."
580
580
msgstr ""
581
581
582
- #: ../../library/dataclasses.rst:528
582
+ #: ../../library/dataclasses.rst:530
583
583
msgid ""
584
584
"See the section below on init-only variables for ways to pass parameters to :"
585
585
"meth:`__post_init__`. Also see the warning about how :func:`replace` "
586
586
"handles ``init=False`` fields."
587
587
msgstr ""
588
588
589
- #: ../../library/dataclasses.rst:533
589
+ #: ../../library/dataclasses.rst:535
590
590
msgid "Class variables"
591
591
msgstr ""
592
592
593
- #: ../../library/dataclasses.rst:535
593
+ #: ../../library/dataclasses.rst:537
594
594
msgid ""
595
595
"One of two places where :func:`dataclass` actually inspects the type of a "
596
596
"field is to determine if a field is a class variable as defined in :pep:"
@@ -600,11 +600,11 @@ msgid ""
600
600
"pseudo-fields are not returned by the module-level :func:`fields` function."
601
601
msgstr ""
602
602
603
- #: ../../library/dataclasses.rst:544
603
+ #: ../../library/dataclasses.rst:546
604
604
msgid "Init-only variables"
605
605
msgstr ""
606
606
607
- #: ../../library/dataclasses.rst:546
607
+ #: ../../library/dataclasses.rst:548
608
608
msgid ""
609
609
"The other place where :func:`dataclass` inspects a type annotation is to "
610
610
"determine if a field is an init-only variable. It does this by seeing if "
@@ -616,23 +616,23 @@ msgid ""
616
616
"`__post_init__` method. They are not otherwise used by dataclasses."
617
617
msgstr ""
618
618
619
- #: ../../library/dataclasses.rst:556
619
+ #: ../../library/dataclasses.rst:558
620
620
msgid ""
621
621
"For example, suppose a field will be initialized from a database, if a value "
622
622
"is not provided when creating the class::"
623
623
msgstr ""
624
624
625
- #: ../../library/dataclasses.rst:571
625
+ #: ../../library/dataclasses.rst:573
626
626
msgid ""
627
627
"In this case, :func:`fields` will return :class:`Field` objects for ``i`` "
628
628
"and ``j``, but not for ``database``."
629
629
msgstr ""
630
630
631
- #: ../../library/dataclasses.rst:575
631
+ #: ../../library/dataclasses.rst:577
632
632
msgid "Frozen instances"
633
633
msgstr ""
634
634
635
- #: ../../library/dataclasses.rst:577
635
+ #: ../../library/dataclasses.rst:579
636
636
msgid ""
637
637
"It is not possible to create truly immutable Python objects. However, by "
638
638
"passing ``frozen=True`` to the :meth:`dataclass` decorator you can emulate "
@@ -641,18 +641,18 @@ msgid ""
641
641
"`FrozenInstanceError` when invoked."
642
642
msgstr ""
643
643
644
- #: ../../library/dataclasses.rst:583
644
+ #: ../../library/dataclasses.rst:585
645
645
msgid ""
646
646
"There is a tiny performance penalty when using ``frozen=True``: :meth:"
647
647
"`__init__` cannot use simple assignment to initialize fields, and must use :"
648
648
"meth:`object.__setattr__`."
649
649
msgstr ""
650
650
651
- #: ../../library/dataclasses.rst:588
651
+ #: ../../library/dataclasses.rst:590
652
652
msgid "Inheritance"
653
653
msgstr ""
654
654
655
- #: ../../library/dataclasses.rst:590
655
+ #: ../../library/dataclasses.rst:592
656
656
msgid ""
657
657
"When the dataclass is being created by the :meth:`dataclass` decorator, it "
658
658
"looks through all of the class's base classes in reverse MRO (that is, "
@@ -664,95 +664,95 @@ msgid ""
664
664
"derived classes override base classes. An example::"
665
665
msgstr ""
666
666
667
- #: ../../library/dataclasses.rst:610
667
+ #: ../../library/dataclasses.rst:612
668
668
msgid ""
669
669
"The final list of fields is, in order, ``x``, ``y``, ``z``. The final type "
670
670
"of ``x`` is ``int``, as specified in class ``C``."
671
671
msgstr ""
672
672
673
- #: ../../library/dataclasses.rst:613
673
+ #: ../../library/dataclasses.rst:615
674
674
msgid "The generated :meth:`__init__` method for ``C`` will look like::"
675
675
msgstr ""
676
676
677
- #: ../../library/dataclasses.rst:618
677
+ #: ../../library/dataclasses.rst:620
678
678
msgid "Re-ordering of keyword-only parameters in :meth:`__init__`"
679
679
msgstr ""
680
680
681
- #: ../../library/dataclasses.rst:620
681
+ #: ../../library/dataclasses.rst:622
682
682
msgid ""
683
683
"After the parameters needed for :meth:`__init__` are computed, any keyword-"
684
684
"only parameters are moved to come after all regular (non-keyword-only) "
685
685
"parameters. This is a requirement of how keyword-only parameters are "
686
686
"implemented in Python: they must come after non-keyword-only parameters."
687
687
msgstr ""
688
688
689
- #: ../../library/dataclasses.rst:626
689
+ #: ../../library/dataclasses.rst:628
690
690
msgid ""
691
691
"In this example, ``Base.y``, ``Base.w``, and ``D.t`` are keyword-only "
692
692
"fields, and ``Base.x`` and ``D.z`` are regular fields::"
693
693
msgstr ""
694
694
695
- #: ../../library/dataclasses.rst:641
695
+ #: ../../library/dataclasses.rst:643
696
696
msgid "The generated :meth:`__init__` method for ``D`` will look like::"
697
697
msgstr ""
698
698
699
- #: ../../library/dataclasses.rst:645
699
+ #: ../../library/dataclasses.rst:647
700
700
msgid ""
701
701
"Note that the parameters have been re-ordered from how they appear in the "
702
702
"list of fields: parameters derived from regular fields are followed by "
703
703
"parameters derived from keyword-only fields."
704
704
msgstr ""
705
705
706
- #: ../../library/dataclasses.rst:649
706
+ #: ../../library/dataclasses.rst:651
707
707
msgid ""
708
708
"The relative ordering of keyword-only parameters is maintained in the re-"
709
709
"ordered :meth:`__init__` parameter list."
710
710
msgstr ""
711
711
712
- #: ../../library/dataclasses.rst:654
712
+ #: ../../library/dataclasses.rst:656
713
713
msgid "Default factory functions"
714
714
msgstr ""
715
715
716
- #: ../../library/dataclasses.rst:656
716
+ #: ../../library/dataclasses.rst:658
717
717
msgid ""
718
718
"If a :func:`field` specifies a ``default_factory``, it is called with zero "
719
719
"arguments when a default value for the field is needed. For example, to "
720
720
"create a new instance of a list, use::"
721
721
msgstr ""
722
722
723
- #: ../../library/dataclasses.rst:662
723
+ #: ../../library/dataclasses.rst:664
724
724
msgid ""
725
725
"If a field is excluded from :meth:`__init__` (using ``init=False``) and the "
726
726
"field also specifies ``default_factory``, then the default factory function "
727
727
"will always be called from the generated :meth:`__init__` function. This "
728
728
"happens because there is no other way to give the field an initial value."
729
729
msgstr ""
730
730
731
- #: ../../library/dataclasses.rst:669
731
+ #: ../../library/dataclasses.rst:671
732
732
msgid "Mutable default values"
733
733
msgstr ""
734
734
735
- #: ../../library/dataclasses.rst:671
735
+ #: ../../library/dataclasses.rst:673
736
736
msgid ""
737
737
"Python stores default member variable values in class attributes. Consider "
738
738
"this example, not using dataclasses::"
739
739
msgstr ""
740
740
741
- #: ../../library/dataclasses.rst:686
741
+ #: ../../library/dataclasses.rst:688
742
742
msgid ""
743
743
"Note that the two instances of class ``C`` share the same class variable "
744
744
"``x``, as expected."
745
745
msgstr ""
746
746
747
- #: ../../library/dataclasses.rst:689
747
+ #: ../../library/dataclasses.rst:691
748
748
msgid "Using dataclasses, *if* this code was valid::"
749
749
msgstr ""
750
750
751
- #: ../../library/dataclasses.rst:697
751
+ #: ../../library/dataclasses.rst:699
752
752
msgid "it would generate code similar to::"
753
753
msgstr ""
754
754
755
- #: ../../library/dataclasses.rst:708
755
+ #: ../../library/dataclasses.rst:710
756
756
msgid ""
757
757
"This has the same issue as the original example using class ``C``. That is, "
758
758
"two instances of class ``D`` that do not specify a value for ``x`` when "
@@ -765,7 +765,7 @@ msgid ""
765
765
"errors."
766
766
msgstr ""
767
767
768
- #: ../../library/dataclasses.rst:719
768
+ #: ../../library/dataclasses.rst:721
769
769
msgid ""
770
770
"Using default factory functions is a way to create new instances of mutable "
771
771
"types as default values for fields::"
0 commit comments