-
-
Notifications
You must be signed in to change notification settings - Fork 224
Expand file tree
/
Copy pathdataclasses.po
More file actions
1703 lines (1548 loc) · 67.4 KB
/
Copy pathdataclasses.po
File metadata and controls
1703 lines (1548 loc) · 67.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
# Copyright (C) 2001-2024, Python Software Foundation
# This file is distributed under the same license as the Python package.
msgid ""
msgstr ""
"Project-Id-Version: Python 3.13\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2025-06-27 07:36+0000\n"
"PO-Revision-Date: 2023-02-11 15:02+0800\n"
"Last-Translator: \n"
"Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-"
"tw)\n"
"Language: zh_TW\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"X-Generator: Poedit 3.2.2\n"
#: ../../library/dataclasses.rst:2
msgid ":mod:`!dataclasses` --- Data Classes"
msgstr ":mod:`!dataclasses` --- Data Classes"
#: ../../library/dataclasses.rst:10
msgid "**Source code:** :source:`Lib/dataclasses.py`"
msgstr "**原始碼:**\\ :source:`Lib/dataclasses.py`"
#: ../../library/dataclasses.rst:14
#, fuzzy
msgid ""
"This module provides a decorator and functions for automatically adding "
"generated :term:`special methods <special method>` such as :meth:`~object."
"__init__` and :meth:`~object.__repr__` to user-defined classes. It was "
"originally described in :pep:`557`."
msgstr ""
"該模組提供了一個裝飾器和函式,用於自動新增生成的\\ :term:`特殊方法 <special "
"method>`,例如 :meth:`~object.__init__` 和 :meth:`~object.__repr__` 到使用者"
"定義的類別。它最初在 :pep:`557` 中描述。"
#: ../../library/dataclasses.rst:19
#, fuzzy
msgid ""
"The member variables to use in these generated methods are defined using :"
"pep:`526` type annotations. For example, this code::"
msgstr ""
"在這些生成的方法中使用的成員變數是使用 :pep:`526` 型別註釋定義的。例如,這段"
"程式碼: ::"
#: ../../library/dataclasses.rst:22
msgid ""
"from dataclasses import dataclass\n"
"\n"
"@dataclass\n"
"class InventoryItem:\n"
" \"\"\"Class for keeping track of an item in inventory.\"\"\"\n"
" name: str\n"
" unit_price: float\n"
" quantity_on_hand: int = 0\n"
"\n"
" def total_cost(self) -> float:\n"
" return self.unit_price * self.quantity_on_hand"
msgstr ""
#: ../../library/dataclasses.rst:34
#, fuzzy
msgid "will add, among other things, a :meth:`!__init__` that looks like::"
msgstr "將新增,除其他事項外,一個 :meth:`!__init__` 看起來像: ::"
#: ../../library/dataclasses.rst:36
msgid ""
"def __init__(self, name: str, unit_price: float, quantity_on_hand: int = "
"0):\n"
" self.name = name\n"
" self.unit_price = unit_price\n"
" self.quantity_on_hand = quantity_on_hand"
msgstr ""
#: ../../library/dataclasses.rst:41
#, fuzzy
msgid ""
"Note that this method is automatically added to the class: it is not "
"directly specified in the :class:`!InventoryItem` definition shown above."
msgstr ""
"請注意,此方法會自動新增到類別中:它不會在上面顯示的 :class:`!InventoryItem` "
"定義中直接指定。"
#: ../../library/dataclasses.rst:47
msgid "Module contents"
msgstr "模組內容"
#: ../../library/dataclasses.rst:51
#, fuzzy
msgid ""
"This function is a :term:`decorator` that is used to add generated :term:"
"`special methods <special method>` to classes, as described below."
msgstr ""
"此函式是一個 :term:`decorator`,用於將生成的\\ :term:`特殊方法 <special "
"method>`\\新增到類別中,如下所述。"
#: ../../library/dataclasses.rst:54
#, fuzzy
msgid ""
"The ``@dataclass`` decorator examines the class to find ``field``\\s. A "
"``field`` is defined as a class variable that has a :term:`type annotation "
"<variable annotation>`. With two exceptions described below, nothing in "
"``@dataclass`` examines the type specified in the variable annotation."
msgstr ""
"``@dataclass`` 裝飾器檢查類別以找到 ``field``\\s。 ``field`` 被定義為具有 :"
"term:`type annotation <variable annotation>` 的類別變數。除了下面描述的兩個例"
"外,``@dataclass`` 中沒有任何內容檢查變數註釋中指定的型別。"
#: ../../library/dataclasses.rst:60
#, fuzzy
msgid ""
"The order of the fields in all of the generated methods is the order in "
"which they appear in the class definition."
msgstr "所有生成的方法中欄位的順序是它們在類別定義中出現的順序。"
#: ../../library/dataclasses.rst:63
msgid ""
"The ``@dataclass`` decorator will add various \"dunder\" methods to the "
"class, described below. If any of the added methods already exist in the "
"class, the behavior depends on the parameter, as documented below. The "
"decorator returns the same class that it is called on; no new class is "
"created."
msgstr ""
"如下所述,``@dataclass`` 裝飾器會向類別新增各種 \"dunder\" 方法。如果類別中已"
"存在任何新增的方法,則行為會取決於參數,如下方文件所述。裝飾器會回傳呼叫它的"
"同一個類別;不會建立新類別。"
#: ../../library/dataclasses.rst:69
#, fuzzy
msgid ""
"If ``@dataclass`` is used just as a simple decorator with no parameters, it "
"acts as if it has the default values documented in this signature. That is, "
"these three uses of ``@dataclass`` are equivalent::"
msgstr ""
"如果 ``@dataclass`` 僅用作不帶參數的簡單裝飾器,它的行為就好像它具有此簽名中"
"記錄的預設值一樣。也就是說,``@dataclass`` 的這三種用法是等價的: ::"
#: ../../library/dataclasses.rst:74
msgid ""
"@dataclass\n"
"class C:\n"
" ...\n"
"\n"
"@dataclass()\n"
"class C:\n"
" ...\n"
"\n"
"@dataclass(init=True, repr=True, eq=True, order=False, unsafe_hash=False, "
"frozen=False,\n"
" match_args=True, kw_only=False, slots=False, weakref_slot=False)\n"
"class C:\n"
" ..."
msgstr ""
"@dataclass\n"
"class C:\n"
" ...\n"
"\n"
"@dataclass()\n"
"class C:\n"
" ...\n"
"\n"
"@dataclass(init=True, repr=True, eq=True, order=False, unsafe_hash=False, "
"frozen=False,\n"
" match_args=True, kw_only=False, slots=False, weakref_slot=False)\n"
"class C:\n"
" ..."
#: ../../library/dataclasses.rst:87
msgid "The parameters to ``@dataclass`` are:"
msgstr "``@dataclass`` 的參數是:"
#: ../../library/dataclasses.rst:89
#, fuzzy
msgid ""
"*init*: If true (the default), a :meth:`~object.__init__` method will be "
"generated."
msgstr "*init*:如果為真(預設值),將生成一個 :meth:`~object.__init__` 方法。"
#: ../../library/dataclasses.rst:92
#, fuzzy
msgid ""
"If the class already defines :meth:`!__init__`, this parameter is ignored."
msgstr "如果該類別已經定義了 :meth:`!__init__`,則忽略此參數。"
#: ../../library/dataclasses.rst:95
#, fuzzy
msgid ""
"*repr*: If true (the default), a :meth:`~object.__repr__` method will be "
"generated. The generated repr string will have the class name and the name "
"and repr of each field, in the order they are defined in the class. Fields "
"that are marked as being excluded from the repr are not included. For "
"example: ``InventoryItem(name='widget', unit_price=3.0, "
"quantity_on_hand=10)``."
msgstr ""
"*repr*:如果為真(預設值),將生成一個 :meth:`__repr__` 方法。生成的 repr 字"
"串將包含類別名稱以及每個欄位的名稱和 repr,按照它們在類別中定義的順序排列。不"
"包括標記為從 repr 中排除的欄位。例如:``InventoryItem(name='widget', "
"unit_price=3.0, quantity_on_hand=10)``。"
#: ../../library/dataclasses.rst:102
msgid ""
"If the class already defines :meth:`!__repr__`, this parameter is ignored."
msgstr "如果該類別已經定義了 :meth:`!__repr__`,則此參數會被忽略。"
#: ../../library/dataclasses.rst:105
#, fuzzy
msgid ""
"*eq*: If true (the default), an :meth:`~object.__eq__` method will be "
"generated. This method compares the class as if it were a tuple of its "
"fields, in order. Both instances in the comparison must be of the identical "
"type."
msgstr ""
"*eq*:如果為真(預設值),將生成一個 :meth:`~object.__eq__` 方法。此方法按順"
"序比較類別,就好像它是其欄位的元組一樣。比較中的兩個實例必須屬於同一型別。"
#: ../../library/dataclasses.rst:110
msgid ""
"If the class already defines :meth:`!__eq__`, this parameter is ignored."
msgstr "如果該類別已經定義了 :meth:`!__eq__`,則此參數會被忽略。"
#: ../../library/dataclasses.rst:113
#, fuzzy
msgid ""
"*order*: If true (the default is ``False``), :meth:`~object.__lt__`, :meth:"
"`~object.__le__`, :meth:`~object.__gt__`, and :meth:`~object.__ge__` methods "
"will be generated. These compare the class as if it were a tuple of its "
"fields, in order. Both instances in the comparison must be of the identical "
"type. If *order* is true and *eq* is false, a :exc:`ValueError` is raised."
msgstr ""
"*order*:如果為真(預設為 ``False``),:meth:`~object.__lt__`、:meth:"
"`~object.__le__`、:meth:`~object.__gt__` 和 :meth:`~object.__ge__` 方法將是產"
"生。它們按順序比較類別,就好像它是其欄位的元組一樣。比較中的兩個實例必須屬於"
"同一型別。如果 *order* 為真且 *eq* 為假,則會引發 :exc:`ValueError`。"
#: ../../library/dataclasses.rst:120
msgid ""
"If the class already defines any of :meth:`!__lt__`, :meth:`!__le__`, :meth:"
"`!__gt__`, or :meth:`!__ge__`, then :exc:`TypeError` is raised."
msgstr ""
"如果該類別已經定義了 :meth:`!__lt__`、:meth:`!__le__`、:meth:`!__gt__` 或 :"
"meth:`!__ge__` 中的任何一個,則引發 :exc:`TypeError`。"
#: ../../library/dataclasses.rst:124
#, fuzzy
msgid ""
"*unsafe_hash*: If true, force ``dataclasses`` to create a :meth:`~object."
"__hash__` method, even though it may not be safe to do so. Otherwise, "
"generate a :meth:`~object.__hash__` method according to how *eq* and "
"*frozen* are set. The default value is ``False``."
msgstr ""
"*unsafe_hash*:如果 ``False``(預設值),將根據 *eq* 和 *frozen* 的設定生成一"
"個 :meth:`~object.__hash__` 方法。"
#: ../../library/dataclasses.rst:130
#, fuzzy
msgid ""
":meth:`!__hash__` is used by built-in :meth:`hash`, and when objects are "
"added to hashed collections such as dictionaries and sets. Having a :meth:`!"
"__hash__` implies that instances of the class are immutable. Mutability is a "
"complicated property that depends on the programmer's intent, the existence "
"and behavior of :meth:`!__eq__`, and the values of the *eq* and *frozen* "
"flags in the ``@dataclass`` decorator."
msgstr ""
":meth:`!__hash__` 由內建的 :meth:`hash` 使用,當對像被新增到散列集合(如字典"
"和集合)時。擁有 :meth:`!__hash__` 意味著該類別的實例是不可變的。可變性是一個"
"複雜的屬性,它取決於程序員的意圖 :meth:`!__eq__` 的存在和行為,以及 "
"dataclass 裝飾器中的 *eq* 和 *frozen* 旗標的值."
#: ../../library/dataclasses.rst:137
#, fuzzy
msgid ""
"By default, ``@dataclass`` will not implicitly add a :meth:`~object."
"__hash__` method unless it is safe to do so. Neither will it add or change "
"an existing explicitly defined :meth:`!__hash__` method. Setting the class "
"attribute ``__hash__ = None`` has a specific meaning to Python, as described "
"in the :meth:`!__hash__` documentation."
msgstr ""
"預設情況下,``@dataclass`` 不會隱式新增 :meth:`~object.__hash__` 方法,除非這"
"樣做是安全的。它也不會新增或更改現有的明確定義的 :meth:`!__hash__` 方法。設定"
"類別屬性 ``__hash__ = None`` 對 Python 具有特定含義,如 :meth:`!__hash__` 文"
"件中所述。"
#: ../../library/dataclasses.rst:143
#, fuzzy
msgid ""
"If :meth:`!__hash__` is not explicitly defined, or if it is set to ``None``, "
"then ``@dataclass`` *may* add an implicit :meth:`!__hash__` method. Although "
"not recommended, you can force ``@dataclass`` to create a :meth:`!__hash__` "
"method with ``unsafe_hash=True``. This might be the case if your class is "
"logically immutable but can still be mutated. This is a specialized use case "
"and should be considered carefully."
msgstr ""
"如果 :meth:`!__hash__` 沒有明確定義,或者如果它被設定為 ``None``,那麼 "
"``@dataclass`` *可能* 新增一個隱式的 :meth:`!__hash__` 方法。雖然不推薦,但你"
"可以強制 ``@dataclass`` 使用 ``unsafe_hash=True`` 建立一個 :meth:`!__hash__` "
"方法。如果你的類別在邏輯上是不可變的但仍然可以改變,則可能是這種情況。這是一"
"個特殊的用例,應該仔細考慮。"
#: ../../library/dataclasses.rst:150
#, fuzzy
msgid ""
"Here are the rules governing implicit creation of a :meth:`!__hash__` "
"method. Note that you cannot both have an explicit :meth:`!__hash__` method "
"in your dataclass and set ``unsafe_hash=True``; this will result in a :exc:"
"`TypeError`."
msgstr ""
"以下是管理隱式建立 :meth:`!__hash__` 方法的規則。請注意,你不能在資料類別中既"
"有顯式的 :meth:`!__hash__` 方法又設定 ``unsafe_hash=True``;這將導致 :exc:"
"`TypeError`。"
#: ../../library/dataclasses.rst:155
#, fuzzy
msgid ""
"If *eq* and *frozen* are both true, by default ``@dataclass`` will generate "
"a :meth:`!__hash__` method for you. If *eq* is true and *frozen* is false, :"
"meth:`!__hash__` will be set to ``None``, marking it unhashable (which it "
"is, since it is mutable). If *eq* is false, :meth:`!__hash__` will be left "
"untouched meaning the :meth:`!__hash__` method of the superclass will be "
"used (if the superclass is :class:`object`, this means it will fall back to "
"id-based hashing)."
msgstr ""
"如果 *eq* 和 *frozen* 都為真,預設情況下 ``@dataclass`` 會為你生成一個:meth:"
"`!__hash__` 方法。如果 ``eq`` 為真且 ``frozen`` 為假,:meth:`!__hash__` 將被"
"設定為 ``None``,將其標記為不可散列(它是不可散列的,因為它是可變的)。如果 "
"``eq`` 為假,:meth:`!__hash__` 將保持不變,這意味著將使用超類別的 :meth:`!"
"__hash__` 方法(如果超類別是 :class:`object`,這意味著它將回退到基於 id 的散"
"列)。"
#: ../../library/dataclasses.rst:163
#, fuzzy
msgid ""
"*frozen*: If true (the default is ``False``), assigning to fields will "
"generate an exception. This emulates read-only frozen instances. If :meth:"
"`~object.__setattr__` or :meth:`~object.__delattr__` is defined in the "
"class, then :exc:`TypeError` is raised. See the discussion below."
msgstr ""
"*frozen*:如果為真(預設為 ``False``),分配給欄位將產生例外。這模擬了只讀的"
"凍結實例。如果 :meth:`~object.__setattr__` 或 :meth:`~object.__delattr__` 在"
"類別中定義,則 :exc:`TypeError` 被引發。請參閱下面的討論。"
#: ../../library/dataclasses.rst:168
#, fuzzy
msgid ""
"*match_args*: If true (the default is ``True``), the :attr:`~object."
"__match_args__` tuple will be created from the list of non keyword-only "
"parameters to the generated :meth:`~object.__init__` method (even if :meth:`!"
"__init__` is not generated, see above). If false, or if :attr:`!"
"__match_args__` is already defined in the class, then :attr:`!"
"__match_args__` will not be generated."
msgstr ""
"*match_args*:如果為真(預設為 ``True``),``__match_args__`` 元組將從參數列"
"表建立到生成的 :meth:`~object.__init__` 方法(即使 :meth: `!__init__` 未生"
"成,見上文)。如果為 false,或者類別中已經定義了 :attr:`!__match_args__`,則"
"不會生成 :attr:`!__match_args__`。"
#: ../../library/dataclasses.rst:177
#, fuzzy
msgid ""
"*kw_only*: If true (the default value is ``False``), then all fields will be "
"marked as keyword-only. If a field is marked as keyword-only, then the only "
"effect is that the :meth:`~object.__init__` parameter generated from a "
"keyword-only field must be specified with a keyword when :meth:`!__init__` "
"is called. See the :term:`parameter` glossary entry for details. Also see "
"the :const:`KW_ONLY` section."
msgstr ""
"``kw_only``:如果為 true(預設值為 ``False``),則所有欄位將被標記為僅限關鍵"
"字。如果一個欄位被標記為僅限關鍵字,那麼唯一的影響是從僅限關鍵字欄位生成的 :"
"meth:`~object.__init__` 參數必須在呼叫 :meth:`!__init__` 時指定關鍵字。對資料"
"類別的任何其他方面都沒有影響。有關詳細資訊,請參閱 :term:`parameter` 詞彙表條"
"目。另請參閱 :const:`KW_ONLY` 部分。"
#: ../../library/dataclasses.rst:185
msgid "Keyword-only fields are not included in :attr:`!__match_args__`."
msgstr ""
#: ../../library/dataclasses.rst:189
#, fuzzy
msgid ""
"*slots*: If true (the default is ``False``), :attr:`~object.__slots__` "
"attribute will be generated and new class will be returned instead of the "
"original one. If :attr:`!__slots__` is already defined in the class, then :"
"exc:`TypeError` is raised."
msgstr ""
"``slots``:如果為 true(預設為 ``False``),將生成 :attr:`~object.__slots__` "
"屬性並回傳新類別而不是原始類別。如果 :attr:`!__slots__` 已經在類別中定義,"
"則 :exc:`TypeError` 被引發。"
#: ../../library/dataclasses.rst:195
#, fuzzy
msgid ""
"Calling no-arg :func:`super` in dataclasses using ``slots=True`` will result "
"in the following exception being raised: ``TypeError: super(type, obj): obj "
"must be an instance or subtype of type``. The two-arg :func:`super` is a "
"valid workaround. See :gh:`90562` for full details."
msgstr ""
"``slots``:如果為 true(預設為 ``False``),將生成 :attr:`~object.__slots__` "
"屬性並回傳新類別而不是原始類別。如果 :attr:`!__slots__` 已經在類別中定義,"
"則 :exc:`TypeError` 被引發。"
#: ../../library/dataclasses.rst:202
msgid ""
"Passing parameters to a base class :meth:`~object.__init_subclass__` when "
"using ``slots=True`` will result in a :exc:`TypeError`. Either use "
"``__init_subclass__`` with no parameters or use default values as a "
"workaround. See :gh:`91126` for full details."
msgstr ""
#: ../../library/dataclasses.rst:210
#, fuzzy
msgid ""
"If a field name is already included in the :attr:`!__slots__` of a base "
"class, it will not be included in the generated :attr:`!__slots__` to "
"prevent :ref:`overriding them <datamodel-note-slots>`. Therefore, do not "
"use :attr:`!__slots__` to retrieve the field names of a dataclass. Use :func:"
"`fields` instead. To be able to determine inherited slots, base class :attr:"
"`!__slots__` may be any iterable, but *not* an iterator."
msgstr ""
"如果欄位名稱已經包含在基底類別的 :attr:`!__slots__` 中,它將不會包含在生成"
"的 :attr:`!__slots__` 中以防止 :ref:`覆蓋它們 <datamodel-note-slots>`。因此,"
"不要使用 __slots__ 來檢索資料類別的欄位名稱。使用 :func:`fields` 代替。為了能"
"夠確定繼承的插槽,基底類別 :attr:`!__slots__` 可以是任何可疊代的,但*不是*疊"
"代器。"
#: ../../library/dataclasses.rst:220
#, fuzzy
msgid ""
"*weakref_slot*: If true (the default is ``False``), add a slot named "
"\"__weakref__\", which is required to make an instance :func:`weakref-able "
"<weakref.ref>`. It is an error to specify ``weakref_slot=True`` without also "
"specifying ``slots=True``."
msgstr ""
"*weakref_slot*:如果為真(預設為 ``False``),新增一個名為 \"__weakref__\" 的"
"插槽,這是使實例可弱引用所必需的。在沒有指定 ``slots=True`` 的情況下指定 "
"``weakref_slot=True`` 是錯誤的。"
#: ../../library/dataclasses.rst:228
#, fuzzy
msgid ""
"``field``\\s may optionally specify a default value, using normal Python "
"syntax::"
msgstr "``field``\\s 可以選擇指定一個預設值,使用普通的 Python 語法: ::"
#: ../../library/dataclasses.rst:231
msgid ""
"@dataclass\n"
"class C:\n"
" a: int # 'a' has no default value\n"
" b: int = 0 # assign a default value for 'b'"
msgstr ""
#: ../../library/dataclasses.rst:236
#, fuzzy
msgid ""
"In this example, both :attr:`!a` and :attr:`!b` will be included in the "
"added :meth:`~object.__init__` method, which will be defined as::"
msgstr ""
"在此示例中,:attr:`!a` 和 :attr:`!b` 都將包含在新增的 :meth:`~object."
"__init__` 方法中,該方法將定義為: ::"
#: ../../library/dataclasses.rst:239
msgid "def __init__(self, a: int, b: int = 0):"
msgstr "def __init__(self, a: int, b: int = 0):"
#: ../../library/dataclasses.rst:241
#, fuzzy
msgid ""
":exc:`TypeError` will be raised if a field without a default value follows a "
"field with a default value. This is true whether this occurs in a single "
"class, or as a result of class inheritance."
msgstr ""
":exc:`TypeError` 如果沒有預設值的欄位跟在具有預設值的欄位之後,將引發。無論這"
"發生在單個類別中還是作為類別繼承的結果,都是如此。"
#: ../../library/dataclasses.rst:247
#, fuzzy
msgid ""
"For common and simple use cases, no other functionality is required. There "
"are, however, some dataclass features that require additional per-field "
"information. To satisfy this need for additional information, you can "
"replace the default field value with a call to the provided :func:`!field` "
"function. For example::"
msgstr ""
"對於常見和簡單的用例,不需要其他功能。但是,有些資料類別功能需要額外的每個欄"
"位資訊。為了滿足這種對附加資訊的需求,你可以通過呼叫提供的 :func:`!field` 函"
"式來替換預設欄位值。例如: ::"
#: ../../library/dataclasses.rst:253
msgid ""
"@dataclass\n"
"class C:\n"
" mylist: list[int] = field(default_factory=list)\n"
"\n"
"c = C()\n"
"c.mylist += [1, 2, 3]"
msgstr ""
"@dataclass\n"
"class C:\n"
" mylist: list[int] = field(default_factory=list)\n"
"\n"
"c = C()\n"
"c.mylist += [1, 2, 3]"
#: ../../library/dataclasses.rst:260
#, fuzzy
msgid ""
"As shown above, the :const:`MISSING` value is a sentinel object used to "
"detect if some parameters are provided by the user. This sentinel is used "
"because ``None`` is a valid value for some parameters with a distinct "
"meaning. No code should directly use the :const:`MISSING` value."
msgstr ""
"如上所示,:const:`MISSING` 值是一個哨兵物件,用於檢測某些參數是否由使用者提"
"供。使用此標記是因為 ``None`` 對於某些具有不同含義的參數是有效值。任何程式碼"
"都不應直接使用 :const:`MISSING` 值。"
#: ../../library/dataclasses.rst:265
msgid "The parameters to :func:`!field` are:"
msgstr ":func:`!field` 的參數是:"
#: ../../library/dataclasses.rst:267
#, fuzzy
msgid ""
"*default*: If provided, this will be the default value for this field. This "
"is needed because the :func:`!field` call itself replaces the normal "
"position of the default value."
msgstr ""
"*default*:如果提供,這將是該欄位的預設值。這是必需的,因為 :meth:`!field` 呼"
"叫本身會替換預設值的正常位置。"
#: ../../library/dataclasses.rst:271
#, fuzzy
msgid ""
"*default_factory*: If provided, it must be a zero-argument callable that "
"will be called when a default value is needed for this field. Among other "
"purposes, this can be used to specify fields with mutable default values, as "
"discussed below. It is an error to specify both *default* and "
"*default_factory*."
msgstr ""
"*default_factory*:如果提供,它必須是一個零引數可呼叫函式,當此欄位需要預設值"
"時將被呼叫。除其他用途外,這可用於指定具有可變預設值的欄位,如下所述。同時指"
"定 *default* 和 *default_factory* 是錯誤的。"
#: ../../library/dataclasses.rst:277
#, fuzzy
msgid ""
"*init*: If true (the default), this field is included as a parameter to the "
"generated :meth:`~object.__init__` method."
msgstr ""
"*init*:如果為 true(預設值),則此欄位將作為生成的 :meth:`~object.__init__` "
"方法的參數包含在內。"
#: ../../library/dataclasses.rst:280
#, fuzzy
msgid ""
"*repr*: If true (the default), this field is included in the string returned "
"by the generated :meth:`~object.__repr__` method."
msgstr ""
"*repr*:如果為真(預設值),則此欄位包含在生成的 :meth:`~object.__repr__` 方"
"法回傳的字串中。"
#: ../../library/dataclasses.rst:283
#, fuzzy
msgid ""
"*hash*: This can be a bool or ``None``. If true, this field is included in "
"the generated :meth:`~object.__hash__` method. If false, this field is "
"excluded from the generated :meth:`~object.__hash__`. If ``None`` (the "
"default), use the value of *compare*: this would normally be the expected "
"behavior, since a field should be included in the hash if it's used for "
"comparisons. Setting this value to anything other than ``None`` is "
"discouraged."
msgstr ""
"*hash*:這可以是 bool 或 ``None``。如果為真,則此欄位包含在生成的 :meth:"
"`__hash__` 方法中。如果 ``None``\\ (預設值),則使用\\ *比較*\\ 的值:這通常"
"是預期的行為。如果一個欄位用於比較,則應在雜湊中考慮該欄位。不鼓勵將此值設定"
"為 ``None`` 以外的任何值。"
#: ../../library/dataclasses.rst:291
#, fuzzy
msgid ""
"One possible reason to set ``hash=False`` but ``compare=True`` would be if a "
"field is expensive to compute a hash value for, that field is needed for "
"equality testing, and there are other fields that contribute to the type's "
"hash value. Even if a field is excluded from the hash, it will still be "
"used for comparisons."
msgstr ""
"設定 ``hash=False`` 但 ``compare=True`` 的一個可能原因是,如果一個欄位計算雜"
"湊值的成本很高,則需要該欄位進行相等性測試,並且還有其他欄位有助於型別的雜湊"
"值。即使一個欄位被排除在雜湊之外,它仍然會被用於比較。"
#: ../../library/dataclasses.rst:297
#, fuzzy
msgid ""
"*compare*: If true (the default), this field is included in the generated "
"equality and comparison methods (:meth:`~object.__eq__`, :meth:`~object."
"__gt__`, et al.)."
msgstr ""
"*compare*:如果為真(預設值),則此欄位包含在生成的相等和比較方法中(:meth:"
"`~object.__eq__`、:meth:`~object.__gt__` 等)。"
#: ../../library/dataclasses.rst:301
#, fuzzy
msgid ""
"*metadata*: This can be a mapping or ``None``. ``None`` is treated as an "
"empty dict. This value is wrapped in :func:`~types.MappingProxyType` to "
"make it read-only, and exposed on the :class:`Field` object. It is not used "
"at all by Data Classes, and is provided as a third-party extension "
"mechanism. Multiple third-parties can each have their own key, to use as a "
"namespace in the metadata."
msgstr ""
"*metadata*:這可以是對映或無。 None 被視為空字典。此值包含在 :func:`~types."
"MappingProxyType` 中以使其成為只讀的,並暴露在 :class:`Field` 對像上。它根本"
"不被資料類別使用,而是作為第三方擴充機制提供的。多個第三方可以各自擁有自己的"
"密鑰,用作元資料中的命名空間。"
#: ../../library/dataclasses.rst:309
#, fuzzy
msgid ""
"*kw_only*: If true, this field will be marked as keyword-only. This is used "
"when the generated :meth:`~object.__init__` method's parameters are computed."
msgstr ""
"*kw_only*:如果為真,該欄位將被標記為僅限關鍵字。這在計算生成的 :meth:"
"`~object.__init__` 方法的參數時使用。"
#: ../../library/dataclasses.rst:313
msgid "Keyword-only fields are also not included in :attr:`!__match_args__`."
msgstr ""
#: ../../library/dataclasses.rst:317
#, fuzzy
msgid ""
"If the default value of a field is specified by a call to :func:`!field`, "
"then the class attribute for this field will be replaced by the specified "
"*default* value. If *default* is not provided, then the class attribute "
"will be deleted. The intent is that after the :func:`@dataclass "
"<dataclass>` decorator runs, the class attributes will all contain the "
"default values for the fields, just as if the default value itself were "
"specified. For example, after::"
msgstr ""
"如果欄位的預設值是通過呼叫 :func:`!field` 指定的,那麼該欄位的類別屬性將被指"
"定的 *default* 值替換。如果沒有提供 *default*,那麼類別屬性將被刪除。目的是"
"在 :func:`@dataclass <dataclass>` 裝飾器運行後,類別屬性將全部包含欄位的預設"
"值,就像預設值本身已指定一樣。例如,在: ::"
#: ../../library/dataclasses.rst:326
msgid ""
"@dataclass\n"
"class C:\n"
" x: int\n"
" y: int = field(repr=False)\n"
" z: int = field(repr=False, default=10)\n"
" t: int = 20"
msgstr ""
"@dataclass\n"
"class C:\n"
" x: int\n"
" y: int = field(repr=False)\n"
" z: int = field(repr=False, default=10)\n"
" t: int = 20"
#: ../../library/dataclasses.rst:333
#, fuzzy
msgid ""
"The class attribute :attr:`!C.z` will be ``10``, the class attribute :attr:`!"
"C.t` will be ``20``, and the class attributes :attr:`!C.x` and :attr:`!C.y` "
"will not be set."
msgstr ""
"類別屬性 :attr:`!C.z` 將為 ``10``,類別屬性 :attr:`!C.t` 將為 ``20``,類別屬"
"性 :attr:`!C.x` 和 :attr:`!C.y` 將不會放。"
#: ../../library/dataclasses.rst:339
#, fuzzy
msgid ""
":class:`!Field` objects describe each defined field. These objects are "
"created internally, and are returned by the :func:`fields` module-level "
"method (see below). Users should never instantiate a :class:`!Field` object "
"directly. Its documented attributes are:"
msgstr ""
":class:`!Field` 物件描述每個定義的欄位。這些對像在內部建立,並由 :func:"
"`fields` 模組級方法回傳(見下文)。使用者不應該直接實例化 :class:`!Field` 物"
"件。它記錄的屬性是:"
#: ../../library/dataclasses.rst:344
msgid ":attr:`!name`: The name of the field."
msgstr ":attr:`!name`:欄位的名稱。"
#: ../../library/dataclasses.rst:345
msgid ":attr:`!type`: The type of the field."
msgstr ":attr:`!type`:欄位的型別。"
#: ../../library/dataclasses.rst:346
#, fuzzy
msgid ""
":attr:`!default`, :attr:`!default_factory`, :attr:`!init`, :attr:`!repr`, :"
"attr:`!hash`, :attr:`!compare`, :attr:`!metadata`, and :attr:`!kw_only` have "
"the identical meaning and values as they do in the :func:`field` function."
msgstr ""
":attr:`!default`、:attr:`!default_factory`、:attr:`!init`、:attr:`!repr`、:"
"attr:`!hash`、:attr:`!compare`, :attr:`!metadata` 和 :attr:`!kw_only` 有與它"
"們在 :func:`field` 函式中的含義和值相同。"
#: ../../library/dataclasses.rst:350
#, fuzzy
msgid ""
"Other attributes may exist, but they are private and must not be inspected "
"or relied on."
msgstr "可能存在其他屬性,但它們是私有的,不得檢查或依賴。"
#: ../../library/dataclasses.rst:355
msgid ""
"``InitVar[T]`` type annotations describe variables that are :ref:`init-only "
"<dataclasses-init-only-variables>`. Fields annotated with :class:`!InitVar` "
"are considered pseudo-fields, and thus are neither returned by the :func:"
"`fields` function nor used in any way except adding them as parameters to :"
"meth:`~object.__init__` and an optional :meth:`__post_init__`."
msgstr ""
#: ../../library/dataclasses.rst:364
#, fuzzy
msgid ""
"Returns a tuple of :class:`Field` objects that define the fields for this "
"dataclass. Accepts either a dataclass, or an instance of a dataclass. "
"Raises :exc:`TypeError` if not passed a dataclass or instance of one. Does "
"not return pseudo-fields which are ``ClassVar`` or ``InitVar``."
msgstr ""
"回傳定義此資料類別欄位的 :class:`Field` 物件的元組。接受資料類別或資料類別的"
"實例。如果未傳遞資料類別或其中一個實例,則引發 :exc:`TypeError`。不回傳 "
"``ClassVar`` 或 ``InitVar`` 的偽欄位。"
#: ../../library/dataclasses.rst:371
#, fuzzy
msgid ""
"Converts the dataclass *obj* to a dict (by using the factory function "
"*dict_factory*). Each dataclass is converted to a dict of its fields, as "
"``name: value`` pairs. dataclasses, dicts, lists, and tuples are recursed "
"into. Other objects are copied with :func:`copy.deepcopy`."
msgstr ""
"將資料類別 *obj* 轉換為字典(通過使用工廠函式 *dict_factory*)。每個資料類別"
"都被轉換為其欄位的字典,作為 ``name: value`` 對。資料類別、字典、列表和元組被"
"遞迴到。其他物件使用 :func:`copy.deepcopy` 複製。"
#: ../../library/dataclasses.rst:377
#, fuzzy
msgid "Example of using :func:`!asdict` on nested dataclasses::"
msgstr "在嵌套資料類別上使用 :func:`!asdict` 的範例: ::"
#: ../../library/dataclasses.rst:379
msgid ""
"@dataclass\n"
"class Point:\n"
" x: int\n"
" y: int\n"
"\n"
"@dataclass\n"
"class C:\n"
" mylist: list[Point]\n"
"\n"
"p = Point(10, 20)\n"
"assert asdict(p) == {'x': 10, 'y': 20}\n"
"\n"
"c = C([Point(0, 0), Point(10, 4)])\n"
"assert asdict(c) == {'mylist': [{'x': 0, 'y': 0}, {'x': 10, 'y': 4}]}"
msgstr ""
"@dataclass\n"
"class Point:\n"
" x: int\n"
" y: int\n"
"\n"
"@dataclass\n"
"class C:\n"
" mylist: list[Point]\n"
"\n"
"p = Point(10, 20)\n"
"assert asdict(p) == {'x': 10, 'y': 20}\n"
"\n"
"c = C([Point(0, 0), Point(10, 4)])\n"
"assert asdict(c) == {'mylist': [{'x': 0, 'y': 0}, {'x': 10, 'y': 4}]}"
#: ../../library/dataclasses.rst:394 ../../library/dataclasses.rst:414
#, fuzzy
msgid "To create a shallow copy, the following workaround may be used::"
msgstr "要建立淺複製,可以使用以下解決方法:"
#: ../../library/dataclasses.rst:396
msgid "{field.name: getattr(obj, field.name) for field in fields(obj)}"
msgstr ""
#: ../../library/dataclasses.rst:398
#, fuzzy
msgid ""
":func:`!asdict` raises :exc:`TypeError` if *obj* is not a dataclass instance."
msgstr ":func:`!asdict` 如果 *obj* 不是資料類別實例,則引發 :exc:`TypeError`。"
#: ../../library/dataclasses.rst:403
#, fuzzy
msgid ""
"Converts the dataclass *obj* to a tuple (by using the factory function "
"*tuple_factory*). Each dataclass is converted to a tuple of its field "
"values. dataclasses, dicts, lists, and tuples are recursed into. Other "
"objects are copied with :func:`copy.deepcopy`."
msgstr ""
"將資料類別 *obj* 轉換為元組(通過使用工廠函式 *tuple_factory*)。每個資料類別"
"都被轉換為其欄位值的元組。資料類別、字典、列表和元組被遞迴到。其他物件使用 :"
"func:`copy.deepcopy` 複製。"
#: ../../library/dataclasses.rst:409
msgid "Continuing from the previous example::"
msgstr "從前面的例子繼續: ::"
#: ../../library/dataclasses.rst:411
msgid ""
"assert astuple(p) == (10, 20)\n"
"assert astuple(c) == ([(0, 0), (10, 4)],)"
msgstr ""
"assert astuple(p) == (10, 20)\n"
"assert astuple(c) == ([(0, 0), (10, 4)],)"
#: ../../library/dataclasses.rst:416
msgid "tuple(getattr(obj, field.name) for field in dataclasses.fields(obj))"
msgstr "tuple(getattr(obj, field.name) for field in dataclasses.fields(obj))"
#: ../../library/dataclasses.rst:418
#, fuzzy
msgid ""
":func:`!astuple` raises :exc:`TypeError` if *obj* is not a dataclass "
"instance."
msgstr ""
":func:`!astuple` 如果 *obj* 不是資料類別實例,則引發 :exc:`TypeError`。"
#: ../../library/dataclasses.rst:423
#, fuzzy
msgid ""
"Creates a new dataclass with name *cls_name*, fields as defined in *fields*, "
"base classes as given in *bases*, and initialized with a namespace as given "
"in *namespace*. *fields* is an iterable whose elements are each either "
"``name``, ``(name, type)``, or ``(name, type, Field)``. If just ``name`` is "
"supplied, :data:`typing.Any` is used for ``type``. The values of *init*, "
"*repr*, *eq*, *order*, *unsafe_hash*, *frozen*, *match_args*, *kw_only*, "
"*slots*, and *weakref_slot* have the same meaning as they do in :func:"
"`@dataclass <dataclass>`."
msgstr ""
"建立一個名為 *cls_name* 的新資料類別,欄位在 *fields* 中定義,基底類別在 "
"*bases* 中給出,並使用 *namespace* 中給出的命名空間進行初始化。 ``fields`` 是"
"一個疊代器,其元素分別是 ``name``、``(name, type)`` 或 ``(name, type, "
"Field)``。如果只提供 ``name``,則 ``typing.Any`` 用於 ``type``。 ``init``、"
"``repr``、``eq``、``order``、``unsafe_hash``、``frozen``、``match_args``、"
"``kw_only`` 的值, ``slots`` 和 ``weakref_slot`` 與它們在 :func:`dataclass` 中"
"的含義相同。"
#: ../../library/dataclasses.rst:433
msgid ""
"If *module* is defined, the :attr:`!__module__` attribute of the dataclass "
"is set to that value. By default, it is set to the module name of the caller."
msgstr ""
#: ../../library/dataclasses.rst:437
#, fuzzy
msgid ""
"This function is not strictly required, because any Python mechanism for "
"creating a new class with :attr:`!__annotations__` can then apply the :func:"
"`@dataclass <dataclass>` function to convert that class to a dataclass. "
"This function is provided as a convenience. For example::"
msgstr ""
"這個函式不是嚴格要求的,因為任何使用 ``__annotations__`` 建立新類別的 Python "
"機制都可以應用 :func:`dataclass` 函式將該類別轉換為資料類別。提供此功能是為了"
"方便。例如: ::"
#: ../../library/dataclasses.rst:443
msgid ""
"C = make_dataclass('C',\n"
" [('x', int),\n"
" 'y',\n"
" ('z', int, field(default=5))],\n"
" namespace={'add_one': lambda self: self.x + 1})"
msgstr ""
"C = make_dataclass('C',\n"
" [('x', int),\n"
" 'y',\n"
" ('z', int, field(default=5))],\n"
" namespace={'add_one': lambda self: self.x + 1})"
#: ../../library/dataclasses.rst:449
msgid "Is equivalent to::"
msgstr "相當於: ::"
#: ../../library/dataclasses.rst:451
msgid ""
"@dataclass\n"
"class C:\n"
" x: int\n"
" y: 'typing.Any'\n"
" z: int = 5\n"
"\n"
" def add_one(self):\n"
" return self.x + 1"
msgstr ""
#: ../../library/dataclasses.rst:462
#, fuzzy
msgid ""
"Creates a new object of the same type as *obj*, replacing fields with values "
"from *changes*. If *obj* is not a Data Class, raises :exc:`TypeError`. If "
"keys in *changes* are not field names of the given dataclass, raises :exc:"
"`TypeError`."
msgstr ""
"建立一個與 ``obj`` 型別相同的新物件,用 ``changes`` 中的值替換欄位。如果 "
"``obj`` 不是資料類別,則引發 :exc:`TypeError`。如果 ``changes`` 中的值未指定"
"欄位,則引發 :exc:`TypeError`。"
#: ../../library/dataclasses.rst:467
#, fuzzy
msgid ""
"The newly returned object is created by calling the :meth:`~object.__init__` "
"method of the dataclass. This ensures that :meth:`__post_init__`, if "
"present, is also called."
msgstr ""
"新回傳的對像是通過呼叫資料類別的 :meth:`~object.__init__` 方法建立的。這確"
"保 :meth:`__post_init__`(如果存在)也被呼叫。"
#: ../../library/dataclasses.rst:471
#, fuzzy
msgid ""
"Init-only variables without default values, if any exist, must be specified "
"on the call to :func:`!replace` so that they can be passed to :meth:`!"
"__init__` and :meth:`__post_init__`."
msgstr ""
"沒有預設值的僅初始化變數(如果存在)必須在呼叫 :func:`replace` 時指定,以便它"
"們可以傳遞給 :meth:`__init__` 和 :meth:`__post_init__`。"
#: ../../library/dataclasses.rst:475
#, fuzzy
msgid ""
"It is an error for *changes* to contain any fields that are defined as "
"having ``init=False``. A :exc:`ValueError` will be raised in this case."
msgstr ""
"*changes* 包含任何定義為具有 ``init=False`` 的欄位是錯誤的。在這種情況下將引"
"發 :exc:`ValueError`。"
#: ../../library/dataclasses.rst:479
#, fuzzy
msgid ""
"Be forewarned about how ``init=False`` fields work during a call to :func:`!"
"replace`. They are not copied from the source object, but rather are "
"initialized in :meth:`__post_init__`, if they're initialized at all. It is "
"expected that ``init=False`` fields will be rarely and judiciously used. If "
"they are used, it might be wise to have alternate class constructors, or "
"perhaps a custom :func:`!replace` (or similarly named) method which handles "
"instance copying."
msgstr ""
"預先警告 ``init=False`` 欄位在呼叫 :func:`!replace` 期間是如何工作的。它們不"
"是從源物件複製的,而是在 :meth:`__post_init__` 中初始化的,如果它們被初始化的"
"話。預計 ``init=False`` 欄位將很少被明智地使用。如果使用它們,使用替代的類別"
"建構函式可能是明智的,或者可能是處理實例複製的自定義:func:`!replace` (或類似"
"命名的)方法。"
#: ../../library/dataclasses.rst:488
msgid ""
"Dataclass instances are also supported by generic function :func:`copy."
"replace`."
msgstr ""
#: ../../library/dataclasses.rst:492
#, fuzzy
msgid ""
"Return ``True`` if its parameter is a dataclass (including subclasses of a "
"dataclass) or an instance of one, otherwise return ``False``."
msgstr ""
"如果它的參數是一個資料類別或一個實例,則回傳 ``True``,否則回傳 ``False``。"
#: ../../library/dataclasses.rst:495
#, fuzzy
msgid ""
"If you need to know if a class is an instance of a dataclass (and not a "
"dataclass itself), then add a further check for ``not isinstance(obj, "
"type)``::"
msgstr ""
"如果你需要知道一個類別是否是資料類別的實例(而不是資料類別本身),那麼新增一"
"個進一步的檢查 ``not isinstance(obj, type)``: ::"
#: ../../library/dataclasses.rst:499
msgid ""
"def is_dataclass_instance(obj):\n"
" return is_dataclass(obj) and not isinstance(obj, type)"
msgstr ""
#: ../../library/dataclasses.rst:504
#, fuzzy
msgid "A sentinel value signifying a missing default or default_factory."
msgstr "表示缺少 default 或 default_factory 的標記值。"
#: ../../library/dataclasses.rst:508
#, fuzzy
msgid ""
"A sentinel value used as a type annotation. Any fields after a pseudo-field "
"with the type of :const:`!KW_ONLY` are marked as keyword-only fields. Note "
"that a pseudo-field of type :const:`!KW_ONLY` is otherwise completely "
"ignored. This includes the name of such a field. By convention, a name of "
"``_`` is used for a :const:`!KW_ONLY` field. Keyword-only fields signify :"
"meth:`~object.__init__` parameters that must be specified as keywords when "
"the class is instantiated."
msgstr ""