-
-
Notifications
You must be signed in to change notification settings - Fork 214
/
Copy pathenum.po
1854 lines (1610 loc) · 62.1 KB
/
enum.po
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
# SOME DESCRIPTIVE TITLE.
# Copyright (C) 2001-2022, Python Software Foundation
# This file is distributed under the same license as the Python package.
#
# Translators:
msgid ""
msgstr ""
"Project-Id-Version: Python 3.13\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2024-12-29 11:18+0000\n"
"PO-Revision-Date: 2024-12-21 13:50+0800\n"
"Last-Translator: Adrian Liaw <adrianliaw2000@gmail.com>\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"
"Plural-Forms: nplurals=1; plural=0;\n"
#: ../../library/enum.rst:2
msgid ":mod:`!enum` --- Support for enumerations"
msgstr ":mod:`!enum` --- 對列舉的支援"
#: ../../library/enum.rst:14
msgid "**Source code:** :source:`Lib/enum.py`"
msgstr "**原始碼:**\\ :source:`Lib/enum.py`"
#: ../../library/enum.rst:18
msgid ""
"This page contains the API reference information. For tutorial information "
"and discussion of more advanced topics, see"
msgstr "本頁包含 API 的參考資訊。關於教學資訊及更多進階主題的討論請參考"
#: ../../library/enum.rst:21
msgid ":ref:`Basic Tutorial <enum-basic-tutorial>`"
msgstr ":ref:`基本教學 <enum-basic-tutorial>`"
#: ../../library/enum.rst:22
msgid ":ref:`Advanced Tutorial <enum-advanced-tutorial>`"
msgstr ":ref:`進階教學 <enum-advanced-tutorial>`"
#: ../../library/enum.rst:23
msgid ":ref:`Enum Cookbook <enum-cookbook>`"
msgstr ":ref:`列舉指南 <enum-cookbook>`"
#: ../../library/enum.rst:27
msgid "An enumeration:"
msgstr "列舉:"
#: ../../library/enum.rst:29
msgid "is a set of symbolic names (members) bound to unique values"
msgstr "是一組綁定唯一值的代表名稱(成員)"
#: ../../library/enum.rst:30
msgid ""
"can be iterated over to return its canonical (i.e. non-alias) members in "
"definition order"
msgstr "可以用疊代的方式以定義的順序回傳其正式 (canonical)(即非別名)成員"
#: ../../library/enum.rst:32
msgid "uses *call* syntax to return members by value"
msgstr "使用 *call* 語法來透過值回傳成員"
#: ../../library/enum.rst:33
msgid "uses *index* syntax to return members by name"
msgstr "使用 *index* 語法來透過名稱回傳成員"
#: ../../library/enum.rst:35
msgid ""
"Enumerations are created either by using :keyword:`class` syntax, or by "
"using function-call syntax::"
msgstr "列舉透過 :keyword:`class` 語法或函式呼叫的語法來建立: ::"
#: ../../library/enum.rst:38
msgid ""
">>> from enum import Enum\n"
"\n"
">>> # class syntax\n"
">>> class Color(Enum):\n"
"... RED = 1\n"
"... GREEN = 2\n"
"... BLUE = 3\n"
"\n"
">>> # functional syntax\n"
">>> Color = Enum('Color', [('RED', 1), ('GREEN', 2), ('BLUE', 3)])"
msgstr ""
">>> from enum import Enum\n"
"\n"
">>> # class 語法\n"
">>> class Color(Enum):\n"
"... RED = 1\n"
"... GREEN = 2\n"
"... BLUE = 3\n"
"\n"
">>> # 函式語法\n"
">>> Color = Enum('Color', [('RED', 1), ('GREEN', 2), ('BLUE', 3)])"
#: ../../library/enum.rst:49
msgid ""
"Even though we can use :keyword:`class` syntax to create Enums, Enums are "
"not normal Python classes. See :ref:`How are Enums different? <enum-class-"
"differences>` for more details."
msgstr ""
"雖然我們可以用 :keyword:`class` 語法來建立列舉,列舉並不是標準的 Python 類"
"別。參考\\ :ref:`列舉有何差異 <enum-class-differences>`\\ 以取得更多細節。"
#: ../../library/enum.rst:53
msgid "Nomenclature"
msgstr "命名方式"
#: ../../library/enum.rst:55
msgid "The class :class:`!Color` is an *enumeration* (or *enum*)"
msgstr ":class:`!Color` 類別是一個\\ *列舉*\\ (或 *enum*)"
#: ../../library/enum.rst:56
msgid ""
"The attributes :attr:`!Color.RED`, :attr:`!Color.GREEN`, etc., are "
"*enumeration members* (or *members*) and are functionally constants."
msgstr ""
":attr:`!Color.RED`、:attr:`!Color.GREEN` 等屬性是\\ *列舉成員*\\ (或\\ *成員"
"*),並且使用上可以看作常數。"
#: ../../library/enum.rst:58
msgid ""
"The enum members have *names* and *values* (the name of :attr:`!Color.RED` "
"is ``RED``, the value of :attr:`!Color.BLUE` is ``3``, etc.)"
msgstr ""
"列舉成員有\\ *名稱*\\ 和\\ *值*\\ (:attr:`!Color.RED` 的名稱是 ``RED``,:"
"attr:`!Color.BLUE` 的值是 ``3`` 諸如此類)"
#: ../../library/enum.rst:65
msgid "Module Contents"
msgstr "模組內容"
#: ../../library/enum.rst:67
msgid ":class:`EnumType`"
msgstr ":class:`EnumType`"
#: ../../library/enum.rst:69
msgid "The ``type`` for Enum and its subclasses."
msgstr "Enum 及其子類別的 ``type``。"
#: ../../library/enum.rst:71
msgid ":class:`Enum`"
msgstr ":class:`Enum`"
#: ../../library/enum.rst:73
msgid "Base class for creating enumerated constants."
msgstr "用來建立列舉常數的基礎類別。"
#: ../../library/enum.rst:75
msgid ":class:`IntEnum`"
msgstr ":class:`IntEnum`"
#: ../../library/enum.rst:77
msgid ""
"Base class for creating enumerated constants that are also subclasses of :"
"class:`int`. (`Notes`_)"
msgstr ""
"用來建立列舉常數的基礎類別,同時也是 :class:`int` 的子類別。(`備註 "
"<Notes_>`_)"
#: ../../library/enum.rst:80
msgid ":class:`StrEnum`"
msgstr ":class:`StrEnum`"
#: ../../library/enum.rst:82
msgid ""
"Base class for creating enumerated constants that are also subclasses of :"
"class:`str`. (`Notes`_)"
msgstr ""
"用來建立列舉常數的基礎類別,同時也是 :class:`str` 的子類別。(`備註 "
"<Notes_>`_)"
#: ../../library/enum.rst:85
msgid ":class:`Flag`"
msgstr ":class:`Flag`"
#: ../../library/enum.rst:87
msgid ""
"Base class for creating enumerated constants that can be combined using the "
"bitwise operations without losing their :class:`Flag` membership."
msgstr ""
"用來建立列舉常數的基礎類別,可以使用位元操作來結合成員且其結果不失去 :class:"
"`Flag` 的成員資格。"
#: ../../library/enum.rst:90
msgid ":class:`IntFlag`"
msgstr ":class:`IntFlag`"
#: ../../library/enum.rst:92
msgid ""
"Base class for creating enumerated constants that can be combined using the "
"bitwise operators without losing their :class:`IntFlag` membership. :class:"
"`IntFlag` members are also subclasses of :class:`int`. (`Notes`_)"
msgstr ""
"用來建立列舉常數的基礎類別,可以使用位元操作來結合成員且其結果不失去 :class:"
"`IntFlag` 的成員資格。:class:`IntFlag` 的成員也是 :class:`int` 的子類別。(`"
"備註 <Notes_>`_)"
#: ../../library/enum.rst:96
msgid ":class:`ReprEnum`"
msgstr ":class:`ReprEnum`"
#: ../../library/enum.rst:98
msgid ""
"Used by :class:`IntEnum`, :class:`StrEnum`, and :class:`IntFlag` to keep "
"the :class:`str() <str>` of the mixed-in type."
msgstr ""
"由 :class:`IntEnum`、:class:`StrEnum` 及 :class:`IntFlag` 所使用來保留這些混"
"合型別的 :class:`str() <str>`。"
#: ../../library/enum.rst:101
msgid ":class:`EnumCheck`"
msgstr ":class:`EnumCheck`"
#: ../../library/enum.rst:103
msgid ""
"An enumeration with the values ``CONTINUOUS``, ``NAMED_FLAGS``, and "
"``UNIQUE``, for use with :func:`verify` to ensure various constraints are "
"met by a given enumeration."
msgstr ""
"一個有 ``CONTINUOUS``、``NAMED_FLAGS`` 及 ``UNIQUE`` 這些值的列舉,和 :func:"
"`verify` 一起使用來確保給定的列舉符合多種限制。"
#: ../../library/enum.rst:107
msgid ":class:`FlagBoundary`"
msgstr ":class:`FlagBoundary`"
#: ../../library/enum.rst:109
msgid ""
"An enumeration with the values ``STRICT``, ``CONFORM``, ``EJECT``, and "
"``KEEP`` which allows for more fine-grained control over how invalid values "
"are dealt with in an enumeration."
msgstr ""
"一個有 ``STRICT``、``CONFORM``、``EJECT`` 及 ``KEEP`` 這些值的列舉,允許列舉"
"對如何處理非法值做更細微的控制。"
#: ../../library/enum.rst:113
msgid ":class:`EnumDict`"
msgstr ":class:`EnumDict`"
#: ../../library/enum.rst:115
msgid "A subclass of :class:`dict` for use when subclassing :class:`EnumType`."
msgstr ":class:`dict` 的子類別,用於當作 :class:`EnumType` 的子類別時使用。"
#: ../../library/enum.rst:117
msgid ":class:`auto`"
msgstr ":class:`auto`"
#: ../../library/enum.rst:119
msgid ""
"Instances are replaced with an appropriate value for Enum members. :class:"
"`StrEnum` defaults to the lower-cased version of the member name, while "
"other Enums default to 1 and increase from there."
msgstr ""
"列舉成員的實例會被取代成合適的值。:class:`StrEnum` 預設是小寫版本的成員名稱,"
"其它列舉則預設是 1 且往後遞增。"
#: ../../library/enum.rst:123
msgid ":func:`~enum.property`"
msgstr ":func:`~enum.property`"
#: ../../library/enum.rst:125
msgid ""
"Allows :class:`Enum` members to have attributes without conflicting with "
"member names. The ``value`` and ``name`` attributes are implemented this "
"way."
msgstr ""
"允許 :class:`Enum` 成員擁有屬性且不會與成員名稱有衝突。``value`` 及 ``name`` "
"屬性是用這個方式來實作。"
#: ../../library/enum.rst:129
msgid ":func:`unique`"
msgstr ":func:`unique`"
#: ../../library/enum.rst:131
msgid ""
"Enum class decorator that ensures only one name is bound to any one value."
msgstr "Enum 類別的裝飾器,用來確保任何值只有綁定到一個名稱上。"
#: ../../library/enum.rst:133
msgid ":func:`verify`"
msgstr ":func:`verify`"
#: ../../library/enum.rst:135
msgid ""
"Enum class decorator that checks user-selectable constraints on an "
"enumeration."
msgstr "Enum 類別的裝飾器,用來檢查列舉上使用者所選的限制。"
#: ../../library/enum.rst:138
msgid ":func:`member`"
msgstr ":func:`member`"
#: ../../library/enum.rst:140
msgid "Make ``obj`` a member. Can be used as a decorator."
msgstr "讓 ``obj`` 變成成員。可以當作裝飾器使用。"
#: ../../library/enum.rst:142
msgid ":func:`nonmember`"
msgstr ":func:`nonmember`"
#: ../../library/enum.rst:144
msgid "Do not make ``obj`` a member. Can be used as a decorator."
msgstr "不讓 ``obj`` 變成成員。可以當作裝飾器使用。"
#: ../../library/enum.rst:146
msgid ":func:`global_enum`"
msgstr ":func:`global_enum`"
#: ../../library/enum.rst:148
msgid ""
"Modify the :class:`str() <str>` and :func:`repr` of an enum to show its "
"members as belonging to the module instead of its class, and export the enum "
"members to the global namespace."
msgstr ""
"修改列舉上的 :class:`str() <str>` 及 :func:`repr` ,讓成員顯示為屬於模組而不"
"是類別,並將該列舉成員匯出到全域命名空間。"
#: ../../library/enum.rst:152
msgid ":func:`show_flag_values`"
msgstr ":func:`show_flag_values`"
#: ../../library/enum.rst:154
msgid "Return a list of all power-of-two integers contained in a flag."
msgstr "回傳旗標 (flag) 裡包含的所有 2 的次方的整數串列。"
#: ../../library/enum.rst:157
msgid "``Flag``, ``IntFlag``, ``auto``"
msgstr "``Flag``, ``IntFlag``, ``auto``"
#: ../../library/enum.rst:158
msgid ""
"``StrEnum``, ``EnumCheck``, ``ReprEnum``, ``FlagBoundary``, ``property``, "
"``member``, ``nonmember``, ``global_enum``, ``show_flag_values``"
msgstr ""
"``StrEnum``, ``EnumCheck``, ``ReprEnum``, ``FlagBoundary``, ``property``, "
"``member``, ``nonmember``, ``global_enum``, ``show_flag_values``"
#: ../../library/enum.rst:159
msgid "``EnumDict``"
msgstr "``EnumDict``"
#: ../../library/enum.rst:164
msgid "Data Types"
msgstr "資料型別"
#: ../../library/enum.rst:169
msgid ""
"*EnumType* is the :term:`metaclass` for *enum* enumerations. It is possible "
"to subclass *EnumType* -- see :ref:`Subclassing EnumType <enumtype-"
"examples>` for details."
msgstr ""
"*EnumType* 是 *enum* 列舉的 :term:`metaclass`。*EnumType* 可以有子類別 -- 細"
"節請參考 :ref:`建立 EnumType 的子類別 <enumtype-examples>`。"
#: ../../library/enum.rst:173
msgid ""
"``EnumType`` is responsible for setting the correct :meth:`!__repr__`, :meth:"
"`!__str__`, :meth:`!__format__`, and :meth:`!__reduce__` methods on the "
"final *enum*, as well as creating the enum members, properly handling "
"duplicates, providing iteration over the enum class, etc."
msgstr ""
"``EnumType`` 負責在最後的\\ *列舉*\\ 上面設定正確的 :meth:`!__repr__`、:meth:"
"`!__str__`、:meth:`!__format__` 及 :meth:`!__reduce__` 方法,以及建立列舉成"
"員、正確處理重複、提供列舉類別的疊代等等。"
#: ../../library/enum.rst:180
msgid "This method is called in two different ways:"
msgstr "這個方法可以用兩種不同的方式呼叫:"
#: ../../library/enum.rst:182
msgid "to look up an existing member:"
msgstr "查詢已存在的成員:"
#: ../../library/enum.rst:0
msgid "cls"
msgstr "cls"
#: ../../library/enum.rst:184 ../../library/enum.rst:190
msgid "The enum class being called."
msgstr "所呼叫的列舉類別。"
#: ../../library/enum.rst:0
msgid "value"
msgstr "value"
#: ../../library/enum.rst:185
msgid "The value to lookup."
msgstr "要查詢的值。"
#: ../../library/enum.rst:187
msgid ""
"to use the ``cls`` enum to create a new enum (only if the existing enum does "
"not have any members):"
msgstr "使用 ``cls`` 列舉來建立新列舉(只有在現有列舉沒有任何成員時)"
#: ../../library/enum.rst:191
msgid "The name of the new Enum to create."
msgstr "要建立的新列舉的名稱。"
#: ../../library/enum.rst:0
msgid "names"
msgstr "names"
#: ../../library/enum.rst:192
msgid "The names/values of the members for the new Enum."
msgstr "新列舉的成員的名稱/值。"
#: ../../library/enum.rst:0
msgid "module"
msgstr "module"
#: ../../library/enum.rst:193
msgid "The name of the module the new Enum is created in."
msgstr "新列舉要建立在哪個模組名稱下。"
#: ../../library/enum.rst:0
msgid "qualname"
msgstr "qualname"
#: ../../library/enum.rst:194
msgid "The actual location in the module where this Enum can be found."
msgstr "這個列舉在模組裡實際上的位置。"
#: ../../library/enum.rst:0
msgid "type"
msgstr "type"
#: ../../library/enum.rst:195
msgid "A mix-in type for the new Enum."
msgstr "新列舉的混合型別。"
#: ../../library/enum.rst:0
msgid "start"
msgstr "start"
#: ../../library/enum.rst:196
msgid "The first integer value for the Enum (used by :class:`auto`)."
msgstr "列舉的第一個整數值(由 :class:`auto` 所使用)"
#: ../../library/enum.rst:0
msgid "boundary"
msgstr "boundary"
#: ../../library/enum.rst:197
msgid ""
"How to handle out-of-range values from bit operations (:class:`Flag` only)."
msgstr "在位元操作時怎麼處理範圍外的值(只有 :class:`Flag` 會用到)"
#: ../../library/enum.rst:201
msgid "Returns ``True`` if member belongs to the ``cls``::"
msgstr "如果 member 屬於 ``cls`` 則回傳 ``True``: ::"
#: ../../library/enum.rst:203
msgid ""
">>> some_var = Color.RED\n"
">>> some_var in Color\n"
"True\n"
">>> Color.RED.value in Color\n"
"True"
msgstr ""
">>> some_var = Color.RED\n"
">>> some_var in Color\n"
"True\n"
">>> Color.RED.value in Color\n"
"True"
#: ../../library/enum.rst:211
msgid ""
"Before Python 3.12, a ``TypeError`` is raised if a non-Enum-member is used "
"in a containment check."
msgstr ""
"在 Python 3.12 之前,如果用非列舉成員做屬於檢查 (containment check) 會引發 "
"``TypeError``。"
#: ../../library/enum.rst:216
msgid ""
"Returns ``['__class__', '__doc__', '__members__', '__module__']`` and the "
"names of the members in *cls*::"
msgstr ""
"回傳 ``['__class__', '__doc__', '__members__', '__module__']`` 及 *cls* 的成"
"員名稱: ::"
#: ../../library/enum.rst:219
msgid ""
">>> dir(Color)\n"
"['BLUE', 'GREEN', 'RED', '__class__', '__contains__', '__doc__', "
"'__getitem__', '__init_subclass__', '__iter__', '__len__', '__members__', "
"'__module__', '__name__', '__qualname__']"
msgstr ""
">>> dir(Color)\n"
"['BLUE', 'GREEN', 'RED', '__class__', '__contains__', '__doc__', "
"'__getitem__', '__init_subclass__', '__iter__', '__len__', '__members__', "
"'__module__', '__name__', '__qualname__']"
#: ../../library/enum.rst:224
msgid ""
"Returns the Enum member in *cls* matching *name*, or raises a :exc:"
"`KeyError`::"
msgstr "回傳 *cls* 中符合 *name* 的列舉成員,或引發 :exc:`KeyError`: ::"
#: ../../library/enum.rst:226
msgid ""
">>> Color['BLUE']\n"
"<Color.BLUE: 3>"
msgstr ""
">>> Color['BLUE']\n"
"<Color.BLUE: 3>"
#: ../../library/enum.rst:231
msgid "Returns each member in *cls* in definition order::"
msgstr "以定義的順序回傳在 *cls* 中的每個成員: ::"
#: ../../library/enum.rst:233
msgid ""
">>> list(Color)\n"
"[<Color.RED: 1>, <Color.GREEN: 2>, <Color.BLUE: 3>]"
msgstr ""
">>> list(Color)\n"
"[<Color.RED: 1>, <Color.GREEN: 2>, <Color.BLUE: 3>]"
#: ../../library/enum.rst:238
msgid "Returns the number of member in *cls*::"
msgstr "回傳 *cls* 的成員數量: ::"
#: ../../library/enum.rst:240
msgid ""
">>> len(Color)\n"
"3"
msgstr ""
">>> len(Color)\n"
"3"
#: ../../library/enum.rst:245
msgid "Returns a mapping of every enum name to its member, including aliases"
msgstr "回傳每個列舉名稱到其成員的對映,包括別名"
#: ../../library/enum.rst:249
msgid "Returns each member in *cls* in reverse definition order::"
msgstr "以跟定義相反的順序回傳 *cls* 的每個成員: ::"
#: ../../library/enum.rst:251
msgid ""
">>> list(reversed(Color))\n"
"[<Color.BLUE: 3>, <Color.GREEN: 2>, <Color.RED: 1>]"
msgstr ""
">>> list(reversed(Color))\n"
"[<Color.BLUE: 3>, <Color.GREEN: 2>, <Color.RED: 1>]"
#: ../../library/enum.rst:256
msgid ""
"Adds a new name as an alias to an existing member. Raises a :exc:"
"`NameError` if the name is already assigned to a different member."
msgstr ""
"新增一個名稱作為現有成員的別名。如果該名稱已被指派給不同的成員,則會引發 :"
"exc:`NameError`。"
#: ../../library/enum.rst:261
msgid ""
"Adds a new value as an alias to an existing member. Raises a :exc:"
"`ValueError` if the value is already linked with a different member."
msgstr ""
"新增一個值作為現有成員的別名。如果該值已與不同成員連結,則會引發 :exc:"
"`ValueError`。"
#: ../../library/enum.rst:266
msgid ""
"Before 3.11 ``EnumType`` was called ``EnumMeta``, which is still available "
"as an alias."
msgstr "在 3.11 之前,``EnumType`` 稱作 ``EnumMeta``,其目前仍可作為別名使用。"
#: ../../library/enum.rst:271
msgid "*Enum* is the base class for all *enum* enumerations."
msgstr "*Enum* 是所有 *enum* 列舉的基礎類別。"
#: ../../library/enum.rst:275
msgid "The name used to define the ``Enum`` member::"
msgstr "用來定義 ``Enum`` 成員的名稱: ::"
#: ../../library/enum.rst:277
msgid ""
">>> Color.BLUE.name\n"
"'BLUE'"
msgstr ""
">>> Color.BLUE.name\n"
"'BLUE'"
#: ../../library/enum.rst:282
msgid "The value given to the ``Enum`` member::"
msgstr "``Enum`` 成員給定的值: ::"
#: ../../library/enum.rst:284
msgid ""
">>> Color.RED.value\n"
"1"
msgstr ""
">>> Color.RED.value\n"
"1"
#: ../../library/enum.rst:287 ../../library/enum.rst:307
msgid "Value of the member, can be set in :meth:`~Enum.__new__`."
msgstr "成員的值,可以在 :meth:`~Enum.__new__` 設定。"
#: ../../library/enum.rst:289
msgid "Enum member values"
msgstr "列舉成員的值"
#: ../../library/enum.rst:291
msgid ""
"Member values can be anything: :class:`int`, :class:`str`, etc. If the "
"exact value is unimportant you may use :class:`auto` instances and an "
"appropriate value will be chosen for you. See :class:`auto` for the details."
msgstr ""
"成員的值可以是任何值::class:`int`、:class:`str` 等等。如果實際使用什麼值並不"
"重要,你可以使用 :class:`auto` 實例,它會為你選擇合適的值。更多細節請參考 :"
"class:`auto`。"
#: ../../library/enum.rst:296
msgid ""
"While mutable/unhashable values, such as :class:`dict`, :class:`list` or a "
"mutable :class:`~dataclasses.dataclass`, can be used, they will have a "
"quadratic performance impact during creation relative to the total number of "
"mutable/unhashable values in the enum."
msgstr ""
"雖然可以使用可變的 (mutable) / 不可雜湊的 (unhashable) 值,例如 :class:"
"`dict`、:class:`list` 或可變的 :class:`~dataclasses.dataclass`,它們在建立期"
"間會對效能產生相對於列舉中可變的 / 不可雜湊的值總數量的二次方影響。"
#: ../../library/enum.rst:303
msgid "Name of the member."
msgstr "成員名稱。"
#: ../../library/enum.rst:311
msgid ""
"No longer used, kept for backward compatibility. (class attribute, removed "
"during class creation)."
msgstr "已不再使用,只為了向後相容而保留(類別屬性,在類別建立時移除)"
#: ../../library/enum.rst:316
msgid ""
"``_ignore_`` is only used during creation and is removed from the "
"enumeration once creation is complete."
msgstr "``_ignore_`` 只有在建立的時候用到,在列舉建立完成後會被移除。"
#: ../../library/enum.rst:319
msgid ""
"``_ignore_`` is a list of names that will not become members, and whose "
"names will also be removed from the completed enumeration. See :ref:"
"`TimePeriod <enum-time-period>` for an example."
msgstr ""
"``_ignore_`` 是一個不會變成成員的名稱串列,在列舉建立完成後其名稱會被移除。範"
"例請參考 :ref:`TimePeriod <enum-time-period>`。"
#: ../../library/enum.rst:325
msgid ""
"Returns ``['__class__', '__doc__', '__module__', 'name', 'value']`` and any "
"public methods defined on *self.__class__*::"
msgstr ""
"回傳 ``['__class__', '__doc__', '__module__', 'name', 'value']`` 及任何 "
"*self.__class__* 上定義的公開方法: ::"
#: ../../library/enum.rst:328
msgid ""
">>> from datetime import date\n"
">>> class Weekday(Enum):\n"
"... MONDAY = 1\n"
"... TUESDAY = 2\n"
"... WEDNESDAY = 3\n"
"... THURSDAY = 4\n"
"... FRIDAY = 5\n"
"... SATURDAY = 6\n"
"... SUNDAY = 7\n"
"... @classmethod\n"
"... def today(cls):\n"
"... print('today is %s' % cls(date.today().isoweekday()).name)\n"
"...\n"
">>> dir(Weekday.SATURDAY)\n"
"['__class__', '__doc__', '__eq__', '__hash__', '__module__', 'name', "
"'today', 'value']"
msgstr ""
">>> from datetime import date\n"
">>> class Weekday(Enum):\n"
"... MONDAY = 1\n"
"... TUESDAY = 2\n"
"... WEDNESDAY = 3\n"
"... THURSDAY = 4\n"
"... FRIDAY = 5\n"
"... SATURDAY = 6\n"
"... SUNDAY = 7\n"
"... @classmethod\n"
"... def today(cls):\n"
"... print('today is %s' % cls(date.today().isoweekday()).name)\n"
"...\n"
">>> dir(Weekday.SATURDAY)\n"
"['__class__', '__doc__', '__eq__', '__hash__', '__module__', 'name', "
"'today', 'value']"
#: ../../library/enum.rst:0
msgid "name"
msgstr "name"
#: ../../library/enum.rst:346
msgid "The name of the member being defined (e.g. 'RED')."
msgstr "定義的成員名稱(例如 'RED')。"
#: ../../library/enum.rst:347
msgid "The start value for the Enum; the default is 1."
msgstr "列舉的開始值,預設為 1。"
#: ../../library/enum.rst:0
msgid "count"
msgstr "count"
#: ../../library/enum.rst:348
msgid "The number of members currently defined, not including this one."
msgstr "已定義的成員數量,不包含目前這一個。"
#: ../../library/enum.rst:0
msgid "last_values"
msgstr "last_values"
#: ../../library/enum.rst:349
msgid "A list of the previous values."
msgstr "一個之前值的串列。"
#: ../../library/enum.rst:351
msgid ""
"A *staticmethod* that is used to determine the next value returned by :class:"
"`auto`::"
msgstr "一個 *staticmethod*,用來決定 :class:`auto` 下一個要回傳的值的: ::"
#: ../../library/enum.rst:354
msgid ""
">>> from enum import auto\n"
">>> class PowersOfThree(Enum):\n"
"... @staticmethod\n"
"... def _generate_next_value_(name, start, count, last_values):\n"
"... return 3 ** (count + 1)\n"
"... FIRST = auto()\n"
"... SECOND = auto()\n"
"...\n"
">>> PowersOfThree.SECOND.value\n"
"9"
msgstr ""
">>> from enum import auto\n"
">>> class PowersOfThree(Enum):\n"
"... @staticmethod\n"
"... def _generate_next_value_(name, start, count, last_values):\n"
"... return 3 ** (count + 1)\n"
"... FIRST = auto()\n"
"... SECOND = auto()\n"
"...\n"
">>> PowersOfThree.SECOND.value\n"
"9"
#: ../../library/enum.rst:367
msgid ""
"By default, does nothing. If multiple values are given in the member "
"assignment, those values become separate arguments to ``__init__``; e.g."
msgstr ""
"預設情況下,不執行任何操作。如果在成員賦值中給出多個值,這些值將成為與 "
"``__init__`` 分別的引數;例如"
#: ../../library/enum.rst:374
msgid ""
"``Weekday.__init__()`` would be called as ``Weekday.__init__(self, 1, "
"'Mon')``"
msgstr "``Weekday.__init__()`` 將被稱為 ``Weekday.__init__(self, 1, 'Mon')``"
#: ../../library/enum.rst:378
msgid ""
"A *classmethod* that is used to further configure subsequent subclasses. By "
"default, does nothing."
msgstr "一個 *classmethod*,用來進一步設定後續的子類別,預設不做任何事。"
#: ../../library/enum.rst:383
msgid ""
"A *classmethod* for looking up values not found in *cls*. By default it "
"does nothing, but can be overridden to implement custom search behavior::"
msgstr ""
"一個 *classmethod*,用來查詢在 *cls* 裡找不到的值。預設不做任何事,但可以被覆"
"寫以實作客製化的搜尋行為: ::"
#: ../../library/enum.rst:386
msgid ""
">>> from enum import StrEnum\n"
">>> class Build(StrEnum):\n"
"... DEBUG = auto()\n"
"... OPTIMIZED = auto()\n"
"... @classmethod\n"
"... def _missing_(cls, value):\n"
"... value = value.lower()\n"
"... for member in cls:\n"
"... if member.value == value:\n"
"... return member\n"
"... return None\n"
"...\n"
">>> Build.DEBUG.value\n"
"'debug'\n"
">>> Build('deBUG')\n"
"<Build.DEBUG: 'debug'>"
msgstr ""
">>> from enum import StrEnum\n"
">>> class Build(StrEnum):\n"
"... DEBUG = auto()\n"
"... OPTIMIZED = auto()\n"
"... @classmethod\n"
"... def _missing_(cls, value):\n"
"... value = value.lower()\n"
"... for member in cls:\n"
"... if member.value == value:\n"
"... return member\n"
"... return None\n"
"...\n"
">>> Build.DEBUG.value\n"
"'debug'\n"
">>> Build('deBUG')\n"
"<Build.DEBUG: 'debug'>"
#: ../../library/enum.rst:405
msgid ""
"By default, doesn't exist. If specified, either in the enum class "
"definition or in a mixin class (such as ``int``), all values given in the "
"member assignment will be passed; e.g."
msgstr ""
"預設情況下不存在。如果有指定,無論是在列舉類別定義中還是在 mixin 類別中(例"
"如 ``int``\\ ),都將傳遞成員賦值中給出的所有值;例如"
#: ../../library/enum.rst:413
msgid ""
"results in the call ``int('1a', 16)`` and a value of ``26`` for the member."
msgstr "會產生呼叫 ``int('1a', 16)`` 而該成員的值為 ``26``。"
#: ../../library/enum.rst:417
msgid ""
"When writing a custom ``__new__``, do not use ``super().__new__`` -- call "
"the appropriate ``__new__`` instead."
msgstr ""
"當寫自訂的 ``__new__`` 時,不要使用 ``super().__new__``,而是要呼叫適當的 "
"``__new__``。"
#: ../../library/enum.rst:422
msgid ""
"Returns the string used for *repr()* calls. By default, returns the *Enum* "
"name, member name, and value, but can be overridden::"
msgstr ""
"回傳呼叫 *repr()* 時使用的字串。預設回傳 *Enum* 名稱、成員名稱及值,但可以被"
"覆寫: ::"
#: ../../library/enum.rst:425
msgid ""
">>> class OtherStyle(Enum):\n"
"... ALTERNATE = auto()\n"
"... OTHER = auto()\n"
"... SOMETHING_ELSE = auto()\n"
"... def __repr__(self):\n"
"... cls_name = self.__class__.__name__\n"
"... return f'{cls_name}.{self.name}'\n"
"...\n"
">>> OtherStyle.ALTERNATE, str(OtherStyle.ALTERNATE), f\"{OtherStyle."
"ALTERNATE}\"\n"
"(OtherStyle.ALTERNATE, 'OtherStyle.ALTERNATE', 'OtherStyle.ALTERNATE')"
msgstr ""
">>> class OtherStyle(Enum):\n"
"... ALTERNATE = auto()\n"
"... OTHER = auto()\n"
"... SOMETHING_ELSE = auto()\n"
"... def __repr__(self):\n"
"... cls_name = self.__class__.__name__\n"
"... return f'{cls_name}.{self.name}'\n"
"...\n"
">>> OtherStyle.ALTERNATE, str(OtherStyle.ALTERNATE), f\"{OtherStyle."
"ALTERNATE}\"\n"
"(OtherStyle.ALTERNATE, 'OtherStyle.ALTERNATE', 'OtherStyle.ALTERNATE')"
#: ../../library/enum.rst:438
msgid ""
"Returns the string used for *str()* calls. By default, returns the *Enum* "
"name and member name, but can be overridden::"
msgstr ""
"回傳呼叫 *str()* 時使用的字串。預設回傳 *Enum* 名稱及成員名稱,但可以被覆"
"寫: ::"
#: ../../library/enum.rst:441
msgid ""
">>> class OtherStyle(Enum):\n"
"... ALTERNATE = auto()\n"
"... OTHER = auto()\n"
"... SOMETHING_ELSE = auto()\n"
"... def __str__(self):\n"
"... return f'{self.name}'\n"
"...\n"
">>> OtherStyle.ALTERNATE, str(OtherStyle.ALTERNATE), f\"{OtherStyle."
"ALTERNATE}\"\n"
"(<OtherStyle.ALTERNATE: 1>, 'ALTERNATE', 'ALTERNATE')"
msgstr ""
">>> class OtherStyle(Enum):\n"
"... ALTERNATE = auto()\n"
"... OTHER = auto()\n"
"... SOMETHING_ELSE = auto()\n"
"... def __str__(self):\n"
"... return f'{self.name}'\n"
"...\n"
">>> OtherStyle.ALTERNATE, str(OtherStyle.ALTERNATE), f\"{OtherStyle."
"ALTERNATE}\"\n"
"(<OtherStyle.ALTERNATE: 1>, 'ALTERNATE', 'ALTERNATE')"
#: ../../library/enum.rst:453
msgid ""
"Returns the string used for *format()* and *f-string* calls. By default, "
"returns :meth:`__str__` return value, but can be overridden::"
msgstr ""
"回傳呼叫 *format()* 及 *f-string* 時使用的字串。預設回傳 :meth:`__str__` 的回"
"傳值,但可以被覆寫: ::"
#: ../../library/enum.rst:456
msgid ""
">>> class OtherStyle(Enum):\n"
"... ALTERNATE = auto()\n"
"... OTHER = auto()\n"
"... SOMETHING_ELSE = auto()\n"
"... def __format__(self, spec):\n"
"... return f'{self.name}'\n"
"...\n"
">>> OtherStyle.ALTERNATE, str(OtherStyle.ALTERNATE), f\"{OtherStyle."
"ALTERNATE}\"\n"
"(<OtherStyle.ALTERNATE: 1>, 'OtherStyle.ALTERNATE', 'ALTERNATE')"
msgstr ""
">>> class OtherStyle(Enum):\n"
"... ALTERNATE = auto()\n"
"... OTHER = auto()\n"
"... SOMETHING_ELSE = auto()\n"
"... def __format__(self, spec):\n"
"... return f'{self.name}'\n"
"...\n"
">>> OtherStyle.ALTERNATE, str(OtherStyle.ALTERNATE), f\"{OtherStyle."
"ALTERNATE}\"\n"
"(<OtherStyle.ALTERNATE: 1>, 'OtherStyle.ALTERNATE', 'ALTERNATE')"
#: ../../library/enum.rst:468
msgid ""
"Using :class:`auto` with :class:`Enum` results in integers of increasing "
"value, starting with ``1``."
msgstr ":class:`Enum` 使用 :class:`auto` 會產生從 ``1`` 開始遞增的整數。"
#: ../../library/enum.rst:471
msgid "Added :ref:`enum-dataclass-support`"
msgstr "新增 :ref:`enum-dataclass-support`"
#: ../../library/enum.rst:476
msgid ""
"*IntEnum* is the same as :class:`Enum`, but its members are also integers "
"and can be used anywhere that an integer can be used. If any integer "
"operation is performed with an *IntEnum* member, the resulting value loses "
"its enumeration status."
msgstr ""
"*IntEnum* 和 :class:`Enum` 一樣,但其成員同時也是整數而可以被用在任何使用整數"
"的地方。如果 *IntEnum* 成員經過任何整數運算,結果值會失去其列舉狀態。"
#: ../../library/enum.rst:497
msgid ""
"Using :class:`auto` with :class:`IntEnum` results in integers of increasing "
"value, starting with ``1``."
msgstr ":class:`IntEnum` 使用 :class:`auto` 會產生從 ``1`` 開始遞增的整數。"
#: ../../library/enum.rst:500
msgid ""
":meth:`~object.__str__` is now :meth:`!int.__str__` to better support the "
"*replacement of existing constants* use-case. :meth:`~object.__format__` was "
"already :meth:`!int.__format__` for that same reason."
msgstr ""
"為了更好地支援\\ *現存常數取代 (replacement of existing constants)* 的使用情"
"境,:meth:`~object.__str__` 現在會是 :meth:`!int.__str__`。為了同樣的理由,:"
"meth:`~object.__format__` 已經是 :meth:`!int.__format__`。"
#: ../../library/enum.rst:507
msgid ""
"``StrEnum`` is the same as :class:`Enum`, but its members are also strings "
"and can be used in most of the same places that a string can be used. The "
"result of any string operation performed on or with a *StrEnum* member is "
"not part of the enumeration."
msgstr ""
"``StrEnum`` 和 :class:`Enum` 一樣,但其成員同時也是字串而可以被用在幾乎所有使"
"用字串的地方。*StrEnum* 成員經過任何字串操作的結果會不再是列舉的一部份。"
#: ../../library/enum.rst:513
msgid ""
"There are places in the stdlib that check for an exact :class:`str` instead "
"of a :class:`str` subclass (i.e. ``type(unknown) == str`` instead of "
"``isinstance(unknown, str)``), and in those locations you will need to use "
"``str(StrEnum.member)``."
msgstr ""
"stdlib 裡有些地方會檢查只能是 :class:`str` 而不是 :class:`str` 的子類別(也就"
"是 ``type(unknown) == str`` 而不是 ``isinstance(unknown, str)``),在這些地方"
"你需要使用 ``str(StrEnum.member)``。"
#: ../../library/enum.rst:520