Repository navigation
Expand file tree
/
Copy pathenum.po
More file actions
3036 lines (2727 loc) · 101 KB
/
Copy pathenum.po
File metadata and controls
3036 lines (2727 loc) · 101 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
# SOME DESCRIPTIVE TITLE.
# Copyright (C) 2001 Python Software Foundation
# This file is distributed under the same license as the Python package.
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
#
# Translators:
# python-doc bot, 2025
# Inada Naoki <songofacandy@gmail.com>, 2026
#
#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: Python 3.15\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2026-11-05 20:53+0000\n"
"PO-Revision-Date: 2025-09-16 00:00+0000\n"
"Last-Translator: Inada Naoki <songofacandy@gmail.com>, 2026\n"
"Language-Team: Japanese (https://app.transifex.com/python-doc/teams/5390/"
"ja/)\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Language: ja\n"
"Plural-Forms: nplurals=1; plural=0;\n"
#: ../../howto/enum.rst:5
msgid "Enum HOWTO"
msgstr "列挙型 HOWTO"
#: ../../howto/enum.rst:11
msgid ""
"An :class:`Enum` is a set of symbolic names bound to unique values. They "
"are similar to global variables, but they offer a more useful :func:`repr`, "
"grouping, type-safety, and a few other features."
msgstr ""
":class:`Enum` は、ユニークな値に束縛されたシンボル名の集合です。グローバル変"
"数に似ていますが、 :func:`repr` がより便利だったり、グルーピングの機能、型安"
"全などいくつかの機能があります。"
#: ../../howto/enum.rst:15
msgid ""
"They are most useful when you have a variable that can take one of a limited "
"selection of values. For example, the days of the week::"
msgstr ""
"これらは、限られた選択肢の値の一つを取る変数がある場合に便利です。例えば、曜"
"日情報があります:"
msgid ""
">>> from enum import Enum\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"
msgstr ""
">>> from enum import Enum\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"
#: ../../howto/enum.rst:28
msgid "Or perhaps the RGB primary colors::"
msgstr "あるいは、RGB三原色でも構いません::"
msgid ""
">>> from enum import Enum\n"
">>> class Color(Enum):\n"
"... RED = 1\n"
"... GREEN = 2\n"
"... BLUE = 3"
msgstr ""
">>> from enum import Enum\n"
">>> class Color(Enum):\n"
"... RED = 1\n"
"... GREEN = 2\n"
"... BLUE = 3"
#: ../../howto/enum.rst:36
msgid ""
"As you can see, creating an :class:`Enum` is as simple as writing a class "
"that inherits from :class:`Enum` itself."
msgstr ""
"ご覧の通り、 :class:`Enum` の作成は :class:`Enum` 自体を継承するクラスを作成"
"するのと同じくらい簡単です。"
#: ../../howto/enum.rst:39
msgid "Case of Enum Members"
msgstr "Enumメンバーは大文字/小文字?"
#: ../../howto/enum.rst:41
msgid ""
"Because Enums are used to represent constants, and to help avoid issues with "
"name clashes between mixin-class methods/attributes and enum names, we "
"strongly recommend using UPPER_CASE names for members, and will be using "
"that style in our examples."
msgstr ""
"列挙型は定数を表すために使われるため、また mixin クラスのメソッドや属性との名"
"前の衝突の問題を回避するため、メンバには UPPER_CASE の名前を使うことが強く推"
"奨されており、例でもこのスタイルを用います。"
#: ../../howto/enum.rst:46
msgid ""
"Depending on the nature of the enum a member's value may or may not be "
"important, but either way that value can be used to get the corresponding "
"member::"
msgstr ""
"列挙型の性質によって、メンバの値は重要な場合とそうでない場合がありますが、い"
"ずれの場合でも、その値は対応するメンバを取得するのに使えます::"
msgid ""
">>> Weekday(3)\n"
"<Weekday.WEDNESDAY: 3>"
msgstr ""
">>> Weekday(3)\n"
"<Weekday.WEDNESDAY: 3>"
#: ../../howto/enum.rst:53
msgid ""
"As you can see, the ``repr()`` of a member shows the enum name, the member "
"name, and the value. The ``str()`` of a member shows only the enum name and "
"member name::"
msgstr ""
"ご覧の通り、メンバの ``repr()`` は列挙型の名前、メンバの名前、そして値を表示"
"します。メンバの ``str()`` は列挙型の名前とメンバの名前のみを表示します。"
msgid ""
">>> print(Weekday.THURSDAY)\n"
"Weekday.THURSDAY"
msgstr ""
">>> print(Weekday.THURSDAY)\n"
"Weekday.THURSDAY"
#: ../../howto/enum.rst:60
msgid "The *type* of an enumeration member is the enum it belongs to::"
msgstr "列挙型のメンバの型はそのメンバの属する列挙型です::"
msgid ""
">>> type(Weekday.MONDAY)\n"
"<enum 'Weekday'>\n"
">>> isinstance(Weekday.FRIDAY, Weekday)\n"
"True"
msgstr ""
">>> type(Weekday.MONDAY)\n"
"<enum 'Weekday'>\n"
">>> isinstance(Weekday.FRIDAY, Weekday)\n"
"True"
msgid "Enum members have an attribute that contains just their :attr:`!name`::"
msgstr ""
"列挙型のメンバーには、その名前だけを保持する :attr:`!name` 属性がありま"
"す。 ::"
msgid ""
">>> print(Weekday.TUESDAY.name)\n"
"TUESDAY"
msgstr ""
">>> print(Weekday.TUESDAY.name)\n"
"TUESDAY"
msgid "Likewise, they have an attribute for their :attr:`!value`::"
msgstr "同様に、値を保持する :attr:`!value` 属性もあります。 ::"
msgid ""
">>> Weekday.WEDNESDAY.value\n"
"3"
msgstr ""
">>> Weekday.WEDNESDAY.value\n"
"3"
msgid ""
"Unlike many languages that treat enumerations solely as name/value pairs, "
"Python Enums can have behavior added. For example, :class:`datetime.date` "
"has two methods for returning the weekday: :meth:`~datetime.date.weekday` "
"and :meth:`~datetime.date.isoweekday`. The difference is that one of them "
"counts from 0-6 and the other from 1-7. Rather than keep track of that "
"ourselves we can add a method to the :class:`!Weekday` enum to extract the "
"day from the :class:`~datetime.date` instance and return the matching enum "
"member::"
msgstr ""
"多くの言語では列挙型を名前と値の組だけとして扱いますが、Python の列挙型には動"
"作を追加できます。\n"
"例えば、:class:`datetime.date` には曜日を返す :meth:`~datetime.date.weekday` "
"と :meth:`~datetime.date.isoweekday` という 2 つのメソッドがあります。\n"
"違いは、一方が 0~6、もう一方が 1~7 で数えることです。\n"
"この違いを自分で管理する代わりに、:class:`!Weekday` 列挙型にメソッドを追加"
"し、:class:`~datetime.date` インスタンスから曜日を取り出して、対応する列挙型"
"メンバーを返すようにできます。 ::"
msgid ""
"@classmethod\n"
"def from_date(cls, date):\n"
" return cls(date.isoweekday())"
msgstr ""
"@classmethod\n"
"def from_date(cls, date):\n"
" return cls(date.isoweekday())"
msgid "The complete :class:`!Weekday` enum now looks like this::"
msgstr ":class:`!Weekday` 列挙型全体は次のようになります。 ::"
msgid ""
">>> 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"
"... #\n"
"... @classmethod\n"
"... def from_date(cls, date):\n"
"... return cls(date.isoweekday())"
msgstr ""
">>> 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"
"... #\n"
"... @classmethod\n"
"... def from_date(cls, date):\n"
"... return cls(date.isoweekday())"
#: ../../howto/enum.rst:106
msgid "Now we can find out what today is! Observe::"
msgstr "さて、これで今日が何曜日か調べることができます! 見てみましょう::"
msgid ""
">>> import datetime as dt\n"
">>> Weekday.from_date(dt.date.today())\n"
"<Weekday.TUESDAY: 2>"
msgstr ""
">>> import datetime as dt\n"
">>> Weekday.from_date(dt.date.today())\n"
"<Weekday.TUESDAY: 2>"
#: ../../howto/enum.rst:112
msgid ""
"Of course, if you're reading this on some other day, you'll see that day "
"instead."
msgstr ""
"もちろん、あなたがこれを読んでいるのが他の曜日ならば、その曜日が代わりに表示"
"されます。"
msgid ""
"This :class:`!Weekday` enum is great if our variable only needs one day, but "
"what if we need several? Maybe we're writing a function to plot chores "
"during a week, and don't want to use a :class:`list` -- we could use a "
"different type of :class:`Enum`::"
msgstr ""
"この :class:`!Weekday` 列挙型は、変数が 1 つの曜日だけを表せばよい場合には便"
"利ですが、複数の曜日が必要ならどうでしょうか?\n"
"例えば、1 週間の家事を割り当てる関数を書いていて、:class:`list` は使いたくな"
"いとします。\n"
"別の種類の :class:`Enum` を使う方法があります。 ::"
msgid ""
">>> from enum import Flag\n"
">>> class Weekday(Flag):\n"
"... MONDAY = 1\n"
"... TUESDAY = 2\n"
"... WEDNESDAY = 4\n"
"... THURSDAY = 8\n"
"... FRIDAY = 16\n"
"... SATURDAY = 32\n"
"... SUNDAY = 64"
msgstr ""
">>> from enum import Flag\n"
">>> class Weekday(Flag):\n"
"... MONDAY = 1\n"
"... TUESDAY = 2\n"
"... WEDNESDAY = 4\n"
"... THURSDAY = 8\n"
"... FRIDAY = 16\n"
"... SATURDAY = 32\n"
"... SUNDAY = 64"
#: ../../howto/enum.rst:129
msgid ""
"We've changed two things: we're inherited from :class:`Flag`, and the values "
"are all powers of 2."
msgstr ""
"ここでは2つの変更が行われています。:class:`Flag` を継承している点と、値がすべ"
"て2の累乗である点です。"
msgid ""
"Just like the original :class:`!Weekday` enum above, we can have a single "
"selection::"
msgstr ""
"先ほどの :class:`!Weekday` 列挙型と同じように、1 つの曜日を選べます。 ::"
msgid ""
">>> first_week_day = Weekday.MONDAY\n"
">>> first_week_day\n"
"<Weekday.MONDAY: 1>"
msgstr ""
">>> first_week_day = Weekday.MONDAY\n"
">>> first_week_day\n"
"<Weekday.MONDAY: 1>"
#: ../../howto/enum.rst:138
msgid ""
"But :class:`Flag` also allows us to combine several members into a single "
"variable::"
msgstr ""
"ただし、:class:`Flag` は複数のメンバーをひとつの変数にまとめることもできま"
"す::"
msgid ""
">>> weekend = Weekday.SATURDAY | Weekday.SUNDAY\n"
">>> weekend\n"
"<Weekday.SATURDAY|SUNDAY: 96>"
msgstr ""
">>> weekend = Weekday.SATURDAY | Weekday.SUNDAY\n"
">>> weekend\n"
"<Weekday.SATURDAY|SUNDAY: 96>"
#: ../../howto/enum.rst:145
msgid "You can even iterate over a :class:`Flag` variable::"
msgstr ":class:`Flag` 変数は反復することもできます::"
msgid ""
">>> for day in weekend:\n"
"... print(day)\n"
"Weekday.SATURDAY\n"
"Weekday.SUNDAY"
msgstr ""
">>> for day in weekend:\n"
"... print(day)\n"
"Weekday.SATURDAY\n"
"Weekday.SUNDAY"
#: ../../howto/enum.rst:152
msgid "Okay, let's get some chores set up::"
msgstr "さて、いくつかの家事を設定してみましょう::"
msgid ""
">>> chores_for_ethan = {\n"
"... 'feed the cat': Weekday.MONDAY | Weekday.WEDNESDAY | "
"Weekday.FRIDAY,\n"
"... 'do the dishes': Weekday.TUESDAY | Weekday.THURSDAY,\n"
"... 'answer SO questions': Weekday.SATURDAY,\n"
"... }"
msgstr ""
">>> chores_for_ethan = {\n"
"... 'feed the cat': Weekday.MONDAY | Weekday.WEDNESDAY | "
"Weekday.FRIDAY,\n"
"... 'do the dishes': Weekday.TUESDAY | Weekday.THURSDAY,\n"
"... 'answer SO questions': Weekday.SATURDAY,\n"
"... }"
#: ../../howto/enum.rst:160
msgid "And a function to display the chores for a given day::"
msgstr "指定された日の家事を表示する関数も作成します::"
msgid ""
">>> def show_chores(chores, day):\n"
"... for chore, days in chores.items():\n"
"... if day in days:\n"
"... print(chore)\n"
"...\n"
">>> show_chores(chores_for_ethan, Weekday.SATURDAY)\n"
"answer SO questions"
msgstr ""
">>> def show_chores(chores, day):\n"
"... for chore, days in chores.items():\n"
"... if day in days:\n"
"... print(chore)\n"
"...\n"
">>> show_chores(chores_for_ethan, Weekday.SATURDAY)\n"
"answer SO questions"
#: ../../howto/enum.rst:170
msgid ""
"In cases where the actual values of the members do not matter, you can save "
"yourself some work and use :func:`auto` for the values::"
msgstr ""
"メンバーの実際の値が重要でない場合は、:func:`auto` を使用することで手間を省く"
"ことができます::"
msgid ""
">>> from enum import auto\n"
">>> class Weekday(Flag):\n"
"... MONDAY = auto()\n"
"... TUESDAY = auto()\n"
"... WEDNESDAY = auto()\n"
"... THURSDAY = auto()\n"
"... FRIDAY = auto()\n"
"... SATURDAY = auto()\n"
"... SUNDAY = auto()\n"
"... WEEKEND = SATURDAY | SUNDAY"
msgstr ""
">>> from enum import auto\n"
">>> class Weekday(Flag):\n"
"... MONDAY = auto()\n"
"... TUESDAY = auto()\n"
"... WEDNESDAY = auto()\n"
"... THURSDAY = auto()\n"
"... FRIDAY = auto()\n"
"... SATURDAY = auto()\n"
"... SUNDAY = auto()\n"
"... WEEKEND = SATURDAY | SUNDAY"
#: ../../howto/enum.rst:189
msgid "Programmatic access to enumeration members and their attributes"
msgstr "列挙型メンバーおよびそれらの属性へのプログラム的アクセス"
msgid ""
"Sometimes it's useful to access members in enumerations programmatically "
"(i.e. situations where ``Color.RED`` won't do because the exact color is not "
"known at program-writing time). ``Enum`` allows such access::"
msgstr ""
"列挙型のメンバーに、プログラムで決めた値を使ってアクセスしたい場合がありま"
"す。\n"
"例えば、プログラムを書く時点では具体的な色が決まっておらず、``Color.RED`` と"
"書けない場合です。\n"
"``Enum`` はそのようなアクセスもできます。 ::"
msgid ""
">>> Color(1)\n"
"<Color.RED: 1>\n"
">>> Color(3)\n"
"<Color.BLUE: 3>"
msgstr ""
">>> Color(1)\n"
"<Color.RED: 1>\n"
">>> Color(3)\n"
"<Color.BLUE: 3>"
#: ../../howto/enum.rst:200
msgid "If you want to access enum members by *name*, use item access::"
msgstr ""
"列挙型メンバーに *名前* でアクセスしたい場合はアイテムとしてアクセスできま"
"す::"
msgid ""
">>> Color['RED']\n"
"<Color.RED: 1>\n"
">>> Color['GREEN']\n"
"<Color.GREEN: 2>"
msgstr ""
">>> Color['RED']\n"
"<Color.RED: 1>\n"
">>> Color['GREEN']\n"
"<Color.GREEN: 2>"
msgid ""
"If you have an enum member and need its :attr:`!name` or :attr:`!value`::"
msgstr ""
"列挙型メンバーから :attr:`!name` や :attr:`!value` を取得するには、次のように"
"します。 ::"
msgid ""
">>> member = Color.RED\n"
">>> member.name\n"
"'RED'\n"
">>> member.value\n"
"1"
msgstr ""
">>> member = Color.RED\n"
">>> member.name\n"
"'RED'\n"
">>> member.value\n"
"1"
#: ../../howto/enum.rst:217
msgid "Duplicating enum members and values"
msgstr "列挙型メンバーと値の重複"
#: ../../howto/enum.rst:219
msgid "Having two enum members with the same name is invalid::"
msgstr "同じ名前の列挙型メンバーを複数持つことはできません::"
msgid ""
">>> class Shape(Enum):\n"
"... SQUARE = 2\n"
"... SQUARE = 3\n"
"...\n"
"Traceback (most recent call last):\n"
"...\n"
"TypeError: 'SQUARE' already defined as 2"
msgstr ""
">>> class Shape(Enum):\n"
"... SQUARE = 2\n"
"... SQUARE = 3\n"
"...\n"
"Traceback (most recent call last):\n"
"...\n"
"TypeError: 'SQUARE' already defined as 2"
msgid ""
"However, an enum member can have other names associated with it. Given two "
"entries ``A`` and ``B`` with the same value (and ``A`` defined first), ``B`` "
"is an alias for the member ``A``. By-value lookup of the value of ``A`` "
"will return the member ``A``. By-name lookup of ``A`` will return the "
"member ``A``. By-name lookup of ``B`` will also return the member ``A``::"
msgstr ""
"しかし、列挙型メンバー は、別の名前を持つことができます。 同じ値を持つ "
"``A`` と ``B`` が与えられた場合(そして ``A`` が先に定義されている場合)、 "
"``B`` はメンバー ``A`` に対するエイリアスとなります。 ``A`` の値での検索で"
"は、メンバー ``A`` が返されます。 ``A`` の名前での検索ではメンバー ``A`` を"
"返します。``B`` の名前での検索も、メンバー ``A`` を返します::"
msgid ""
">>> class Shape(Enum):\n"
"... SQUARE = 2\n"
"... DIAMOND = 1\n"
"... CIRCLE = 3\n"
"... ALIAS_FOR_SQUARE = 2\n"
"...\n"
">>> Shape.SQUARE\n"
"<Shape.SQUARE: 2>\n"
">>> Shape.ALIAS_FOR_SQUARE\n"
"<Shape.SQUARE: 2>\n"
">>> Shape(2)\n"
"<Shape.SQUARE: 2>"
msgstr ""
">>> class Shape(Enum):\n"
"... SQUARE = 2\n"
"... DIAMOND = 1\n"
"... CIRCLE = 3\n"
"... ALIAS_FOR_SQUARE = 2\n"
"...\n"
">>> Shape.SQUARE\n"
"<Shape.SQUARE: 2>\n"
">>> Shape.ALIAS_FOR_SQUARE\n"
"<Shape.SQUARE: 2>\n"
">>> Shape(2)\n"
"<Shape.SQUARE: 2>"
#: ../../howto/enum.rst:250
msgid ""
"Attempting to create a member with the same name as an already defined "
"attribute (another member, a method, etc.) or attempting to create an "
"attribute with the same name as a member is not allowed."
msgstr ""
"すでに定義されている属性と同じ名前のメンバー (一方がメンバーでもう一方がメ"
"ソッド、など) の作成、あるいはメンバーと同じ名前の属性の作成はできません。"
msgid "Ensuring unique enumeration values"
msgstr "列挙型の値が一意であることを保証する"
msgid ""
"By default, enumerations allow multiple names as aliases for the same value. "
"When this behavior isn't desired, you can use the :deco:`unique` decorator::"
msgstr ""
"デフォルトでは、列挙型は同じ値に対する別名として複数の名前を許容します。\n"
"この動作が望ましくない場合は、:deco:`unique` デコレータを使えます。 ::"
msgid ""
">>> from enum import Enum, unique\n"
">>> @unique\n"
"... class Mistake(Enum):\n"
"... ONE = 1\n"
"... TWO = 2\n"
"... THREE = 3\n"
"... FOUR = 3\n"
"...\n"
"Traceback (most recent call last):\n"
"...\n"
"ValueError: duplicate values found in <enum 'Mistake'>: FOUR -> THREE"
msgstr ""
">>> from enum import Enum, unique\n"
">>> @unique\n"
"... class Mistake(Enum):\n"
"... ONE = 1\n"
"... TWO = 2\n"
"... THREE = 3\n"
"... FOUR = 3\n"
"...\n"
"Traceback (most recent call last):\n"
"...\n"
"ValueError: duplicate values found in <enum 'Mistake'>: FOUR -> THREE"
#: ../../howto/enum.rst:275
msgid "Using automatic values"
msgstr "値の自動設定を使う"
#: ../../howto/enum.rst:277
msgid "If the exact value is unimportant you can use :class:`auto`::"
msgstr "正確な値が重要でない場合、 :class:`auto` が使えます::"
msgid ""
">>> from enum import Enum, auto\n"
">>> class Color(Enum):\n"
"... RED = auto()\n"
"... BLUE = auto()\n"
"... GREEN = auto()\n"
"...\n"
">>> [member.value for member in Color]\n"
"[1, 2, 3]"
msgstr ""
">>> from enum import Enum, auto\n"
">>> class Color(Enum):\n"
"... RED = auto()\n"
"... BLUE = auto()\n"
"... GREEN = auto()\n"
"...\n"
">>> [member.value for member in Color]\n"
"[1, 2, 3]"
msgid ""
"The values are chosen by :func:`~Enum._generate_next_value_`, which can be "
"overridden::"
msgstr ""
"値は :func:`~Enum._generate_next_value_` によって選ばれます。\n"
"この関数はオーバーライドできます。 ::"
msgid ""
">>> class AutoName(Enum):\n"
"... @staticmethod\n"
"... def _generate_next_value_(name, start, count, last_values):\n"
"... return name\n"
"...\n"
">>> class Ordinal(AutoName):\n"
"... NORTH = auto()\n"
"... SOUTH = auto()\n"
"... EAST = auto()\n"
"... WEST = auto()\n"
"...\n"
">>> [member.value for member in Ordinal]\n"
"['NORTH', 'SOUTH', 'EAST', 'WEST']"
msgstr ""
">>> class AutoName(Enum):\n"
"... @staticmethod\n"
"... def _generate_next_value_(name, start, count, last_values):\n"
"... return name\n"
"...\n"
">>> class Ordinal(AutoName):\n"
"... NORTH = auto()\n"
"... SOUTH = auto()\n"
"... EAST = auto()\n"
"... WEST = auto()\n"
"...\n"
">>> [member.value for member in Ordinal]\n"
"['NORTH', 'SOUTH', 'EAST', 'WEST']"
msgid ""
"The :meth:`~Enum._generate_next_value_` method must be defined before any "
"members."
msgstr ""
":meth:`~Enum._generate_next_value_` メソッドは、すべてのメンバーより前に定義"
"しなければなりません。"
#: ../../howto/enum.rst:310
msgid "Iteration"
msgstr "イテレーション"
#: ../../howto/enum.rst:312
msgid "Iterating over the members of an enum does not provide the aliases::"
msgstr "列挙型のメンバーのイテレートは別名をサポートしていません::"
msgid ""
">>> list(Shape)\n"
"[<Shape.SQUARE: 2>, <Shape.DIAMOND: 1>, <Shape.CIRCLE: 3>]\n"
">>> list(Weekday)\n"
"[<Weekday.MONDAY: 1>, <Weekday.TUESDAY: 2>, <Weekday.WEDNESDAY: 4>, "
"<Weekday.THURSDAY: 8>, <Weekday.FRIDAY: 16>, <Weekday.SATURDAY: 32>, "
"<Weekday.SUNDAY: 64>]"
msgstr ""
">>> list(Shape)\n"
"[<Shape.SQUARE: 2>, <Shape.DIAMOND: 1>, <Shape.CIRCLE: 3>]\n"
">>> list(Weekday)\n"
"[<Weekday.MONDAY: 1>, <Weekday.TUESDAY: 2>, <Weekday.WEDNESDAY: 4>, "
"<Weekday.THURSDAY: 8>, <Weekday.FRIDAY: 16>, <Weekday.SATURDAY: 32>, "
"<Weekday.SUNDAY: 64>]"
msgid ""
"Note that the aliases ``Shape.ALIAS_FOR_SQUARE`` and ``Weekday.WEEKEND`` "
"aren't shown."
msgstr ""
"エイリアスである ``Shape.ALIAS_FOR_SQUARE`` と ``Weekday.WEEKEND`` が表示され"
"ていないことに注意してください。"
#: ../../howto/enum.rst:321
msgid ""
"The special attribute ``__members__`` is a read-only ordered mapping of "
"names to members. It includes all names defined in the enumeration, "
"including the aliases::"
msgstr ""
"特殊属性 ``__members__`` は読み出し専用で、順序を保持した、対応する名前と列挙"
"型メンバーのマッピングです。これには別名も含め、列挙されたすべての名前が入っ"
"ています。"
msgid ""
">>> for name, member in Shape.__members__.items():\n"
"... name, member\n"
"...\n"
"('SQUARE', <Shape.SQUARE: 2>)\n"
"('DIAMOND', <Shape.DIAMOND: 1>)\n"
"('CIRCLE', <Shape.CIRCLE: 3>)\n"
"('ALIAS_FOR_SQUARE', <Shape.SQUARE: 2>)"
msgstr ""
">>> for name, member in Shape.__members__.items():\n"
"... name, member\n"
"...\n"
"('SQUARE', <Shape.SQUARE: 2>)\n"
"('DIAMOND', <Shape.DIAMOND: 1>)\n"
"('CIRCLE', <Shape.CIRCLE: 3>)\n"
"('ALIAS_FOR_SQUARE', <Shape.SQUARE: 2>)"
#: ../../howto/enum.rst:333
msgid ""
"The ``__members__`` attribute can be used for detailed programmatic access "
"to the enumeration members. For example, finding all the aliases::"
msgstr ""
"属性 ``__members__`` は列挙型メンバーへの詳細なアクセスに使用できます。以下は"
"すべての別名を探す例です::"
msgid ""
">>> [name for name, member in Shape.__members__.items() if member.name != "
"name]\n"
"['ALIAS_FOR_SQUARE']"
msgstr ""
">>> [name for name, member in Shape.__members__.items() if member.name != "
"name]\n"
"['ALIAS_FOR_SQUARE']"
#: ../../howto/enum.rst:341
msgid ""
"Aliases for flags include values with multiple flags set, such as ``3``, and "
"no flags set, i.e. ``0``."
msgstr ""
"フラグのエイリアスには、 複数のフラグが設定された値(例えば ``3``)や、 フラ"
"グが設定されていない値(例えば ``0``)が含まれます。"
#: ../../howto/enum.rst:346
msgid "Comparisons"
msgstr "比較"
#: ../../howto/enum.rst:348
msgid "Enumeration members are compared by identity::"
msgstr "列挙型メンバーは同一性を比較できます::"
msgid ""
">>> Color.RED is Color.RED\n"
"True\n"
">>> Color.RED is Color.BLUE\n"
"False\n"
">>> Color.RED is not Color.BLUE\n"
"True"
msgstr ""
">>> Color.RED is Color.RED\n"
"True\n"
">>> Color.RED is Color.BLUE\n"
"False\n"
">>> Color.RED is not Color.BLUE\n"
"True"
#: ../../howto/enum.rst:357
msgid ""
"Ordered comparisons between enumeration values are *not* supported. Enum "
"members are not integers (but see `IntEnum`_ below)::"
msgstr ""
"列挙型の値の順序の比較はサポートされて *いません*。Enum メンバーは整数ではあ"
"りません (`IntEnum`_ を参照してください)::"
msgid ""
">>> Color.RED < Color.BLUE\n"
"Traceback (most recent call last):\n"
" File \"<stdin>\", line 1, in <module>\n"
"TypeError: '<' not supported between instances of 'Color' and 'Color'"
msgstr ""
">>> Color.RED < Color.BLUE\n"
"Traceback (most recent call last):\n"
" File \"<stdin>\", line 1, in <module>\n"
"TypeError: '<' not supported between instances of 'Color' and 'Color'"
#: ../../howto/enum.rst:365
msgid "Equality comparisons are defined though::"
msgstr "ただし等価の比較は定義されています::"
msgid ""
">>> Color.BLUE == Color.RED\n"
"False\n"
">>> Color.BLUE != Color.RED\n"
"True\n"
">>> Color.BLUE == Color.BLUE\n"
"True"
msgstr ""
">>> Color.BLUE == Color.RED\n"
"False\n"
">>> Color.BLUE != Color.RED\n"
"True\n"
">>> Color.BLUE == Color.BLUE\n"
"True"
msgid ""
"Equality comparisons against non-enumeration values will always return "
"``False`` (again, :class:`IntEnum` was explicitly designed to behave "
"differently, see below)::"
msgstr ""
"列挙型でない値との等価比較は、常に ``False`` を返します。\n"
"ただし、:class:`IntEnum` は明示的に異なる動作をするよう設計されています。\n"
"詳しくは後で説明します。 ::"
msgid ""
">>> Color.BLUE == 2\n"
"False"
msgstr ""
">>> Color.BLUE == 2\n"
"False"
#: ../../howto/enum.rst:383
msgid ""
"It is possible to reload modules -- if a reloaded module contains enums, "
"they will be recreated, and the new members may not compare identical/equal "
"to the original members."
msgstr ""
"モジュールは再読み込みすることが可能です。再読み込みされたモジュールに列挙型"
"が含まれている場合、それらは再作成され、新しいメンバーは元のメンバーと同一で"
"ない/等しくない可能性があります。"
#: ../../howto/enum.rst:388
msgid "Allowed members and attributes of enumerations"
msgstr "列挙型で許されるメンバーと属性"
#: ../../howto/enum.rst:390
msgid ""
"Most of the examples above use integers for enumeration values. Using "
"integers is short and handy (and provided by default by the `Functional "
"API`_), but not strictly enforced. In the vast majority of use-cases, one "
"doesn't care what the actual value of an enumeration is. But if the value "
"*is* important, enumerations can have arbitrary values."
msgstr ""
"これまでのほとんどの例では、列挙型の値に整数を使用しています。 整数を使うの"
"は短くて便利(そして、 `関数 API`_ ではデフォルトで設定される)ですが、これは"
"強制されているわけではありません。大半の使用例では、列挙値の実際の値が何であ"
"るかは意識しません。しかし、値が重要な場合、列挙型は任意の値を持つことができ"
"ます。"
#: ../../howto/enum.rst:396
msgid ""
"Enumerations are Python classes, and can have methods and special methods as "
"usual. If we have this enumeration::"
msgstr ""
"列挙型は Python のクラスであり、通常どおりメソッドや特殊メソッドを持つことが"
"できます::"
msgid ""
">>> class Mood(Enum):\n"
"... FUNKY = 1\n"
"... HAPPY = 3\n"
"...\n"
"... def describe(self):\n"
"... # self is the member here\n"
"... return self.name, self.value\n"
"...\n"
"... def __str__(self):\n"
"... return 'my custom str! {0}'.format(self.value)\n"
"...\n"
"... @classmethod\n"
"... def favorite_mood(cls):\n"
"... # cls here is the enumeration\n"
"... return cls.HAPPY\n"
"..."
msgstr ""
">>> class Mood(Enum):\n"
"... FUNKY = 1\n"
"... HAPPY = 3\n"
"...\n"
"... def describe(self):\n"
"... # ここでは self はメンバー\n"
"... return self.name, self.value\n"
"...\n"
"... def __str__(self):\n"
"... return 'my custom str! {0}'.format(self.value)\n"
"...\n"
"... @classmethod\n"
"... def favorite_mood(cls):\n"
"... # ここでは cls は列挙型\n"
"... return cls.HAPPY\n"
"..."
#: ../../howto/enum.rst:416
msgid "Then::"
msgstr "上記の結果が以下のようになります::"
msgid ""
">>> Mood.favorite_mood()\n"
"<Mood.HAPPY: 3>\n"
">>> Mood.HAPPY.describe()\n"
"('HAPPY', 3)\n"
">>> str(Mood.FUNKY)\n"
"'my custom str! 1'"
msgstr ""
">>> Mood.favorite_mood()\n"
"<Mood.HAPPY: 3>\n"
">>> Mood.HAPPY.describe()\n"
"('HAPPY', 3)\n"
">>> str(Mood.FUNKY)\n"
"'my custom str! 1'"
msgid ""
"The rules for what is allowed are as follows: names that start and end with "
"a single underscore are reserved by enum and cannot be used; all other "
"attributes defined within an enumeration will become members of this "
"enumeration, with the exception of special methods "
"(:meth:`~object.__str__`, :meth:`~object.__add__`, etc.), descriptors "
"(methods are also descriptors), and variable names listed "
"in :attr:`~Enum._ignore_`."
msgstr ""
"使用できるものの規則は次のとおりです。\n"
"先頭と末尾がそれぞれ 1 つのアンダースコアである名前は enum が予約しているため"
"使えません。\n"
"それ以外の、列挙型の中で定義した属性はすべて列挙型のメンバーになります。\n"
"ただし、:meth:`~object.__str__` や :meth:`~object.__add__` などの特殊メソッ"
"ド、デスクリプタ (メソッドもデスクリプタです)、:attr:`~Enum._ignore_` に列挙"
"した変数名は例外です。"
msgid ""
"Note: if your enumeration defines :meth:`~object.__new__` and/"
"or :meth:`~object.__init__`, any value(s) given to the enum member will be "
"passed into those methods. See `Planet`_ for an example."
msgstr ""
"注意: 列挙型に :meth:`~object.__new__` や :meth:`~object.__init__` を定義する"
"と、メンバーに指定した値がそれらのメソッドに渡されます。\n"
"例は `Planet`_ を参照してください。"
msgid ""
"The :meth:`~object.__new__` method, if defined, is used during creation of "
"the Enum members; it is then replaced by Enum's :meth:`~object.__new__` "
"which is used after class creation for lookup of existing members. "
"See :ref:`new-vs-init` for more details."
msgstr ""
":meth:`~object.__new__` を定義した場合、そのメソッドは Enum メンバーの作成時"
"に使われます。\n"
"その後は Enum の :meth:`~object.__new__` に置き換えられ、クラス作成後の既存メ"
"ンバーの検索に使われます。\n"
"詳しくは :ref:`new-vs-init` を参照してください。"
#: ../../howto/enum.rst:445
msgid "Restricted Enum subclassing"
msgstr "Enumのサブクラス化の制限"
msgid ""
"A new :class:`Enum` class must have one base enum class, up to one concrete "
"data type, and as many :class:`object`-based mixin classes as needed. The "
"order of these base classes is::"
msgstr ""
"新しい :class:`Enum` クラスには、基底となる列挙型クラスが 1 つ必要です。\n"
"加えて、具象データ型を最大 1 つ、:class:`object` を基底とするミックスインクラ"
"スを必要なだけ指定できます。\n"
"これらの基底クラスは次の順に並べます。 ::"
msgid ""
"class EnumName([mix-in, ...,] [data-type,] base-enum):\n"
" pass"
msgstr ""
"class EnumName([mix-in, ...,] [data-type,] base-enum):\n"
" pass"
#: ../../howto/enum.rst:454
msgid ""
"Also, subclassing an enumeration is allowed only if the enumeration does not "
"define any members. So this is forbidden::"
msgstr ""
"列挙型のサブクラスの作成はその列挙型にメンバーが一つも定義されていない場合の"
"み行なえます。従って以下は許されません::"
msgid ""
">>> class MoreColor(Color):\n"
"... PINK = 17\n"
"...\n"
"Traceback (most recent call last):\n"
"...\n"
"TypeError: <enum 'MoreColor'> cannot extend <enum 'Color'>"
msgstr ""
">>> class MoreColor(Color):\n"
"... PINK = 17\n"
"...\n"
"Traceback (most recent call last):\n"
"...\n"
"TypeError: <enum 'MoreColor'> cannot extend <enum 'Color'>"
#: ../../howto/enum.rst:464
msgid "But this is allowed::"
msgstr "以下のような場合は許されます::"
msgid ""
">>> class Foo(Enum):\n"
"... def some_behavior(self):\n"
"... pass\n"
"...\n"
">>> class Bar(Foo):\n"
"... HAPPY = 1\n"
"... SAD = 2\n"
"..."