"enum" --- Support for enumerations
***********************************

バージョン 3.4 で追加.

**ソースコード:** Lib/enum.py


Important
^^^^^^^^^

このページには、リファレンス情報だけが含まれています。チュートリアルは
、以下のページを参照してください

* 基本チュートリアル

* 上級チュートリアル

* Enum クックブック

======================================================================

列挙型とは:

* 一意の値に紐付けられたシンボリックな名前の集合です

* 反復可能であり、定義順にその正規の（エイリアスでない）メンバーを返し
  ます

* 値を渡してメンバーを返すために、 *呼び出し* 構文を使用します

* 名前を受け取ってメンバーを返すために、 *インデックス* 構文を使用しま
  す

列挙型は、"class" 構文を使用するか、関数呼び出し構文を使用して作成され
ます:

   >>> from enum import Enum

   >>> # class syntax
   >>> class Color(Enum):
   ...     RED = 1
   ...     GREEN = 2
   ...     BLUE = 3

   >>> # functional syntax
   >>> Color = Enum('Color', ['RED', 'GREEN', 'BLUE'])

Enum の作成に "class" 文を使用できるものの、Enum は通常の Python クラ
スではありません。詳細は Enum はどう違うのか? を参照してください。

注釈:

  用語

  * クラス "Color" は *列挙型* (または *Enum*) です

  * 属性 "Color.RED", "Color.GREEN" などは *列挙型のメンバー* (または
    *メンバー*) で、機能的には定数です。

  * 列挙型のメンバーは *名前* と *値* を持ちます ("Color.RED" の名前は
    "RED" 、 "Color.BLUE" の値は "3" など。)

======================================================================


モジュールコンテンツ
====================

   "EnumType"

      Enumおよびそのサブクラスのための "type" です。

   "Enum"

      列挙型定数を作成する基底クラスです。

   "IntEnum"

      "int" のサブクラスでもある列挙型定数を作成する基底クラスです。
      (Notes)

   "StrEnum"

      "str" のサブクラスでもある列挙型定数を作成する基底クラスです。
      (Notes)

   "Flag"

      列挙型定数を作成する基底クラスで、ビット演算を使って組み合わせら
      れ、その結果も "IntFlag" メンバーになります。

   "IntFlag"

      列挙型定数を作成する基底クラスで、ビット演算子を使って組み合わせ
      られ、その結果も "IntFlag" メンバーになります。 "IntFlag" は
      "int" のサブクラスでもあります。(Notes)

   "ReprEnum"

      "IntEnum"、"StrEnum"、および "IntFlag" によって使用され、mix-in
      された型の "str()" を保持します。

   "EnumCheck"

      "CONTINUOUS"、"NAMED_FLAGS"、"UNIQUE" の値を持つ列挙型です。
      "verify()" と共に使用して、指定された列挙型がさまざまな制約を満
      たしていることを確認します。

   "FlagBoundary"

      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.

   "auto"

      インスタンスは列挙型のメンバーに適切な値で置き換えられます。
      "StrEnum" ではデフォルトの値がメンバー名を小文字にしたものですが
      、その他の列挙型のデフォルトは1から連番で増加する値となります。

   "property()"

      Allows "Enum" members to have attributes without conflicting
      with member names.

   "unique()"

      一つの名前だけがひとつの値に束縛されていることを保証する Enum ク
      ラスのデコレーターです。

   "verify()"

      Enum class decorator that checks user-selectable constraints on
      an enumeration.

   "member()"

      "obj" をメンバーにします。デコレータとして使用できます。

   "nonmember()"

      "obj" をメンバーにしません。デコレータとして使用できます。

   "global_enum()"

      Modify the "str()" and "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.

   "show_flag_values()"

      フラグに含まれる、全ての2の累乗の整数のリストを返します。

バージョン 3.6 で追加: "Flag", "IntFlag", "auto"

バージョン 3.11 で追加: "StrEnum", "EnumCheck", "ReprEnum",
"FlagBoundary", "property", "member", "nonmember", "global_enum",
"show_flag_values"

======================================================================


データ型
========

class enum.EnumType

   *EnumType* は *enum* 列挙型の *メタクラス* です。 *EnumType* のサブ
   クラスを作成することが可能です -- 詳細は EnumTypeのサブクラスを作る
   を参照してください。

   *EnumType* is responsible for setting the correct "__repr__()",
   "__str__()", "__format__()", and "__reduce__()" methods on the
   final *enum*, as well as creating the enum members, properly
   handling duplicates, providing iteration over the enum class, etc.

   __call__(cls, value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)

      このメソッドは2つの異なる方法で呼び出されます。

      * 既存のメンバーを検索する:

           cls:
              呼び出されるenumクラス。

           value:
              検索する値。

      * "cls" を使って新しい列挙型を作成する（既存の列挙型がメンバーを
        持たない場合のみ）:

           cls:
              呼び出されるenumクラス。

           value:
              新しく作成するEnumの名前。

           名前:
              新しく作成するEnumのメンバーの名前/値のリスト。

           module:
              新しく作成するEnumの属するモジュール名。

           qualname:
              The actual location in the module where this Enum can be
              found.

           type:
              新しく作成するEnumのmix-in型。

           start:
              Enumの最初の整数値（"auto" で使用されます）。

           boundary:
              bit演算での範囲外の値の扱い方（"Flag" のみ）。

   __contains__(cls, member)

      メンバーが "cls" に属している場合は "True" を返します:

         >>> some_var = Color.RED
         >>> some_var in Color
         True

      注釈:

        In Python 3.12 it will be possible to check for member values
        and not just members; until then, a "TypeError" will be raised
        if a non-Enum-member is used in a containment check.

   __dir__(cls)

      "['__class__', '__doc__', '__members__', '__module__']" と、
      *cls* に属するメンバー名を返します:

         >>> dir(Color)
         ['BLUE', 'GREEN', 'RED', '__class__', '__contains__', '__doc__', '__getitem__', '__init_subclass__', '__iter__', '__len__', '__members__', '__module__', '__name__', '__qualname__']

   __getattr__(cls, name)

      Returns the Enum member in *cls* matching *name*, or raises an
      "AttributeError":

         >>> Color.GREEN
         <Color.GREEN: 2>

   __getitem__(cls, name)

      *cls* 内の一致するメンバーを返すか、"KeyError" を送出します:

         >>> Color['BLUE']
         <Color.BLUE: 3>

   __iter__(cls)

      Returns each member in *cls* in definition order:

         >>> list(Color)
         [<Color.RED: 1>, <Color.GREEN: 2>, <Color.BLUE: 3>]

   __len__(cls)

      *cls* 内のメンバーの数を返します。:

         >>> len(Color)
         3

   __reversed__(cls)

      *cls* 内の各メンバー を定義順の逆順で返します:

         >>> list(reversed(Color))
         [<Color.BLUE: 3>, <Color.GREEN: 2>, <Color.RED: 1>]

   バージョン 3.11 で追加: Before 3.11 "enum" used "EnumMeta" type,
   which is kept as an alias.

class enum.Enum

   *Enum* は全ての *enum* 列挙型の基底クラスです。

   name

      "Enum" メンバーを定義するために使用される名前:

         >>> Color.BLUE.name
         'BLUE'

   value

      "Enum" メンバーに与えられた値:

         >>> Color.RED.value
         1

      Value of the member, can be set in "__new__()".

      注釈:

        列挙型のメンバー値メンバー値は何であっても構いません: "int",
        "str" などなど。 正確な値が重要でない場合は、 "auto" インスタ
        ンスを使っておくと、適切な値が選ばれます。 詳細は "auto" を参
        照してください。While mutable/unhashable values, such as
        "dict", "list" or a mutable "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.

   _name_

      Name of the member.

   _value_

      Value of the member, can be set in "__new__()".

   _order_

      No longer used, kept for backward compatibility. (class
      attribute, removed during class creation).

   _ignore_

      "_ignore_" は列挙の作成中にのみ使用され、作成が完了すると削除さ
      れます。

      "_ignore_" は、メンバーにならず、作成された列挙から削除される名
      前のリストです。例については、TimePeriod を参照してください。

   __dir__(self)

      Returns "['__class__', '__doc__', '__module__', 'name',
      'value']" and any public methods defined on *self.__class__*:

         >>> from datetime import date
         >>> class Weekday(Enum):
         ...     MONDAY = 1
         ...     TUESDAY = 2
         ...     WEDNESDAY = 3
         ...     THURSDAY = 4
         ...     FRIDAY = 5
         ...     SATURDAY = 6
         ...     SUNDAY = 7
         ...     @classmethod
         ...     def today(cls):
         ...         print('today is %s' % cls(date.today().isoweekday()).name)
         >>> dir(Weekday.SATURDAY)
         ['__class__', '__doc__', '__eq__', '__hash__', '__module__', 'name', 'today', 'value']

   _generate_next_value_(name, start, count, last_values)

         name:
            定義されているメンバーの名前（例：'RED'）。

         start:
            Enumの開始値。デフォルトは1です。

         count:
            定義済みのメンバーの数。現在のメンバーを含めない。

         last_values:
            定義済みの値のリスト。

      "auto" によって返される次の値を決定するために使用される
      *staticmethod*  です:

         >>> from enum import auto
         >>> class PowersOfThree(Enum):
         ...     @staticmethod
         ...     def _generate_next_value_(name, start, count, last_values):
         ...         return 3 ** (count + 1)
         ...     FIRST = auto()
         ...     SECOND = auto()
         >>> PowersOfThree.SECOND.value
         9

   __init_subclass__(cls, **kwds)

      サブクラスを更に設定するために使用される *classmethod* です。デ
      フォルトでは何も行いません。

   _missing_(cls, value)

      *cls* で見つからない値を検索するための *classmethod* です。デフ
      ォルトでは何もしませんが、カスタムの検索の振る舞いを実装するため
      にオーバーライドすることができます:

         >>> from enum import StrEnum
         >>> class Build(StrEnum):
         ...     DEBUG = auto()
         ...     OPTIMIZED = auto()
         ...     @classmethod
         ...     def _missing_(cls, value):
         ...         value = value.lower()
         ...         for member in cls:
         ...             if member.value == value:
         ...                 return member
         ...         return None
         >>> Build.DEBUG.value
         'debug'
         >>> Build('deBUG')
         <Build.DEBUG: 'debug'>

   __repr__(self)

      *repr()* の呼び出しに使用される文字列を返します。デフォルトでは
      、 *Enum* 名、メンバー名、および値を返しますが、オーバーライドす
      ることもできます:

         >>> class OtherStyle(Enum):
         ...     ALTERNATE = auto()
         ...     OTHER = auto()
         ...     SOMETHING_ELSE = auto()
         ...     def __repr__(self):
         ...         cls_name = self.__class__.__name__
         ...         return f'{cls_name}.{self.name}'
         >>> OtherStyle.ALTERNATE, str(OtherStyle.ALTERNATE), f"{OtherStyle.ALTERNATE}"
         (OtherStyle.ALTERNATE, 'OtherStyle.ALTERNATE', 'OtherStyle.ALTERNATE')

   __str__(self)

      *str()* の呼び出しに使用される文字列を返します。デフォルトでは、
      *Enum* の名前とメンバーの名前を返しますが、オーバーライドするこ
      ともできます:

         >>> class OtherStyle(Enum):
         ...     ALTERNATE = auto()
         ...     OTHER = auto()
         ...     SOMETHING_ELSE = auto()
         ...     def __str__(self):
         ...         return f'{self.name}'
         >>> OtherStyle.ALTERNATE, str(OtherStyle.ALTERNATE), f"{OtherStyle.ALTERNATE}"
         (<OtherStyle.ALTERNATE: 1>, 'ALTERNATE', 'ALTERNATE')

   __format__(self)

      *format()* および *f-string* の呼び出しに使用される文字列を返し
      ます。デフォルトでは、"__str__()" の戻り値を返しますが、オーバー
      ライドすることもできます。:

         >>> class OtherStyle(Enum):
         ...     ALTERNATE = auto()
         ...     OTHER = auto()
         ...     SOMETHING_ELSE = auto()
         ...     def __format__(self, spec):
         ...         return f'{self.name}'
         >>> OtherStyle.ALTERNATE, str(OtherStyle.ALTERNATE), f"{OtherStyle.ALTERNATE}"
         (<OtherStyle.ALTERNATE: 1>, 'OtherStyle.ALTERNATE', 'ALTERNATE')

   注釈:

     "Enum" で "auto" を使用すると、 "1" から始まりインクリメントする
     整数が値となります。

class enum.IntEnum

   *IntEnum* is the same as *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.

   >>> from enum import IntEnum
   >>> class Number(IntEnum):
   ...     ONE = 1
   ...     TWO = 2
   ...     THREE = 3
   ...
   >>> Number.THREE
   <Number.THREE: 3>
   >>> Number.ONE + Number.TWO
   3
   >>> Number.THREE + 5
   8
   >>> Number.THREE == 3
   True

   注釈:

     "IntEnum" で "auto" を使用すると、 "1" から始まりインクリメントす
     る整数が値となります。

   バージョン 3.11 で変更: "__str__()" は、既存の定数を置き換えるユー
   スケースをより良くサポートするために "int.__str__()" に変更されまし
   た。同じ理由で、"__format__()" は既に "int.__format__()" に変更され
   ています。

class enum.StrEnum

   *StrEnum* is the same as *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.

   注釈:

     標準ライブラリの中には、 "str" の代わりに "str" のサブクラス（つ
     まり、 "type(unknown) == str" の代わりに "isinstance(unknown,
     str)" ）を厳密にチェックする場所があります。そのような場所では、
     "str(StrEnum.member)" を使用する必要があります。

   注釈:

     "StrEnum" で "auto" を使用すると、メンバー名を小文字に変換したも
     のが値となります。

   注釈:

     "__str__()" は *既存の定数の置換* ユースケースをより良くサポート
     するために "str.__str__()" となりました。 "__format__()" も同様に
     、同じ理由で "str.__format__()" となりました。

   バージョン 3.11 で追加.

class enum.Flag

   *Flag* members support the bitwise operators "&" (*AND*), "|"
   (*OR*), "^" (*XOR*), and "~" (*INVERT*); the results of those
   operators are members of the enumeration.

   __contains__(self, value)

      値を含む場合に *True* を返します:

         >>> from enum import Flag, auto
         >>> class Color(Flag):
         ...     RED = auto()
         ...     GREEN = auto()
         ...     BLUE = auto()
         >>> purple = Color.RED | Color.BLUE
         >>> white = Color.RED | Color.GREEN | Color.BLUE
         >>> Color.GREEN in purple
         False
         >>> Color.GREEN in white
         True
         >>> purple in white
         True
         >>> white in purple
         False

   __iter__(self):

      エイリアスでない、全てのメンバーを返します:

         >>> list(Color.RED)
         [<Color.RED: 1>]
         >>> list(purple)
         [<Color.RED: 1>, <Color.BLUE: 4>]

      バージョン 3.11 で追加.

   __len__(self):

      flag 内のメンバーの数を返します:

         >>> len(Color.GREEN)
         1
         >>> len(white)
         3

   __bool__(self):

      メンバーがflagに含まれている場合は *True* を返し、それ以外の場合
      は *False* を返します:

         >>> bool(Color.GREEN)
         True
         >>> bool(white)
         True
         >>> black = Color(0)
         >>> bool(black)
         False

   __or__(self, other)

      現在のフラグと他のフラグの論理和となるフラグを返します:

         >>> Color.RED | Color.GREEN
         <Color.RED|GREEN: 3>

   __and__(self, other)

      現在のフラグと他のフラグの論理積となるフラグを返します:

         >>> purple & white
         <Color.RED|BLUE: 5>
         >>> purple & Color.GREEN
         <Color: 0>

   __xor__(self, other)

      現在のフラグと他のフラグの排他的論理和となるフラグを返します:

         >>> purple ^ white
         <Color.GREEN: 2>
         >>> purple ^ Color.GREEN
         <Color.RED|GREEN|BLUE: 7>

   __invert__(self):

      Returns all the flags in *type(self)* that are not in self:

         >>> ~white
         <Color: 0>
         >>> ~purple
         <Color.GREEN: 2>
         >>> ~Color.RED
         <Color.GREEN|BLUE: 6>

   _numeric_repr_()

      Function used to format any remaining unnamed numeric values.
      Default is the value's repr; common choices are "hex()" and
      "oct()".

   注釈:

     "auto" と "Flag" を一緒に使うと、"1" から始まる2の累乗の整数にな
     ります。

   バージョン 3.11 で変更: The *repr()* of zero-valued flags has
   changed.  It is now::

   >>> Color(0) 
   <Color: 0>

class enum.IntFlag

   *IntFlag* is the same as *Flag*, but its members are also integers
   and can be used anywhere that an integer can be used.

   >>> from enum import IntFlag, auto
   >>> class Color(IntFlag):
   ...     RED = auto()
   ...     GREEN = auto()
   ...     BLUE = auto()
   >>> Color.RED & 2
   <Color: 0>
   >>> Color.RED | 2
   <Color.RED|GREEN: 3>

   *IntFlag* のメンバーと整数の演算が行われた場合、結果は *IntFlag* で
   はありません:

      >>> Color.RED + 2
      3

   If a *Flag* operation is performed with an *IntFlag* member and:

   * 結果が有効な *IntFlag*: *IntFlag* が返されます

   * the result is not a valid *IntFlag*: the result depends on the
     *FlagBoundary* setting

   The *repr()* of unnamed zero-valued flags has changed.  It is now:

   >>> Color(0)
   <Color: 0>

   注釈:

     "auto" と "IntFlag" を一緒に使うと、"1" から始まる2の累乗の整数に
     なります。

   バージョン 3.11 で変更: "__str__()" は、既存の定数を置き換えるユー
   スケースをより良くサポートするために "int.__str__()" に変更されまし
   た。同じ理由で、"__format__()" は既に "int.__format__()" に変更され
   ています。"IntFlag" の反転は、与えられたフラグ以外のすべてのフラグ
   の結合となる正の値を返すようになりました。これは既存の "Flag" の振
   る舞いに一致します。

class enum.ReprEnum

   "ReprEnum" uses the "repr()" of "Enum", but the "str()" of the
   mixed-in data type:

   * "int.__str__()" for "IntEnum" and "IntFlag"

   * "str.__str__()" for "StrEnum"

   "ReprEnum" を継承することで、"Enum" デフォルトの "str()"  を使用す
   る代わりに、mix-inされたデータ型の "str()"  /  "format()" を使用し
   ます。

   バージョン 3.11 で追加.

class enum.EnumCheck

   *EnumCheck* には "verify()" デコレータやさまざまな制約を保証するた
   めに使用されるオプションが含まれています。制約に違反すると
   "ValueError" が発生します。

   UNIQUE

      それぞれの値が1つの名前しか持たないことを確認します:

         >>> from enum import Enum, verify, UNIQUE
         >>> @verify(UNIQUE)
         ... class Color(Enum):
         ...     RED = 1
         ...     GREEN = 2
         ...     BLUE = 3
         ...     CRIMSON = 1
         Traceback (most recent call last):
         ...
         ValueError: aliases found in <enum 'Color'>: CRIMSON -> RED

   CONTINUOUS

      最小値のメンバーと最大値のメンバーの間に欠損値がないことを確認し
      ます:

         >>> from enum import Enum, verify, CONTINUOUS
         >>> @verify(CONTINUOUS)
         ... class Color(Enum):
         ...     RED = 1
         ...     GREEN = 2
         ...     BLUE = 5
         Traceback (most recent call last):
         ...
         ValueError: invalid enum 'Color': missing values 3, 4

   NAMED_FLAGS

      任意のフラググループ/マスクが、名前付きフラグのみを含むことを確
      認します -- 値を指定するのではなく、"auto()" によって生成される
      場合に便利です:

         >>> from enum import Flag, verify, NAMED_FLAGS
         >>> @verify(NAMED_FLAGS)
         ... class Color(Flag):
         ...     RED = 1
         ...     GREEN = 2
         ...     BLUE = 4
         ...     WHITE = 15
         ...     NEON = 31
         Traceback (most recent call last):
         ...
         ValueError: invalid Flag 'Color': aliases WHITE and NEON are missing combined values of 0x18 [use enum.show_flag_values(value) for details]

   注釈:

     CONTINUOUSとNAMED_FLAGSは整数値のメンバーとともに動作するように設
     計されています。

   バージョン 3.11 で追加.

class enum.FlagBoundary

   *FlagBoundary* controls how out-of-range values are handled in
   *Flag* and its subclasses.

   STRICT

      範囲外の値は "ValueError" を送出します。これは "Flag" のデフォル
      トです:

         >>> from enum import Flag, STRICT, auto
         >>> class StrictFlag(Flag, boundary=STRICT):
         ...     RED = auto()
         ...     GREEN = auto()
         ...     BLUE = auto()
         >>> StrictFlag(2**2 + 2**4)
         Traceback (most recent call last):
         ...
         ValueError: <flag 'StrictFlag'> invalid value 20
             given 0b0 10100
           allowed 0b0 00111

   CONFORM

      Out-of-range values have invalid values removed, leaving a valid
      *Flag* value:

         >>> from enum import Flag, CONFORM, auto
         >>> class ConformFlag(Flag, boundary=CONFORM):
         ...     RED = auto()
         ...     GREEN = auto()
         ...     BLUE = auto()
         >>> ConformFlag(2**2 + 2**4)
         <ConformFlag.BLUE: 4>

   EJECT

      Out-of-range values lose their *Flag* membership and revert to
      "int".

      >>> from enum import Flag, EJECT, auto
      >>> class EjectFlag(Flag, boundary=EJECT):
      ...     RED = auto()
      ...     GREEN = auto()
      ...     BLUE = auto()
      >>> EjectFlag(2**2 + 2**4)
      20

   KEEP

      Out-of-range values are kept, and the *Flag* membership is kept.
      This is the default for "IntFlag":

         >>> from enum import Flag, KEEP, auto
         >>> class KeepFlag(Flag, boundary=KEEP):
         ...     RED = auto()
         ...     GREEN = auto()
         ...     BLUE = auto()
         >>> KeepFlag(2**2 + 2**4)
         <KeepFlag.BLUE|16: 20>

バージョン 3.11 で追加.

======================================================================


"__dunder__" 名のサポート
-------------------------

"__members__" は読み込み専用の、 "member_name":"member"  を要素とする
順序付きマッピングです。これはクラスでのみ利用可能です。

"__new__()", if specified, must create and return the enum members; it
is also a very good idea to set the member's "_value_" appropriately.
Once all the members are created it is no longer used.


"_sunder_" 名のサポート
-----------------------

* "_name_" -- メンバー名

* "_value_" -- メンバーの値; "__new__" で設定できます

* "_missing_()" -- 値が見付からなかったときに使われる検索関数; オーバ
  ーライドされていることがあります

* "_ignore_" -- 名前のリストで、 "list" もしくは "str" です。この名前
  の要素はメンバーへの変換が行われず、最終的なクラスから削除されます。

* "_order_" -- no longer used, kept for backward compatibility (class
  attribute, removed during class creation)

* "_generate_next_value_()" -- 列挙型のメンバーの適切な値を取得するの
  に使われます。オーバーライドされます。

  注釈:

    For standard "Enum" classes the next value chosen is the last
    value seen incremented by one.For "Flag" classes the next value
    chosen will be the next highest power-of-two, regardless of the
    last value seen.

バージョン 3.6 で追加: "_missing_", "_order_", "_generate_next_value_"

バージョン 3.7 で追加: "_ignore_"

======================================================================


ユーティリティとデコレータ
==========================

class enum.auto

   *auto* can be used in place of a value.  If used, the *Enum*
   machinery will call an *Enum*'s "_generate_next_value_()" to get an
   appropriate value. For *Enum* and *IntEnum* that appropriate value
   will be the last value plus one; for *Flag* and *IntFlag* it will
   be the first power-of-two greater than the highest value; for
   *StrEnum* it will be the lower-cased version of the member's name.
   Care must be taken if mixing *auto()* with manually specified
   values.

   *auto* インスタンスは、代入のトップレベルでのみ解決されます。

   * "FIRST = auto()" は動作します（auto() は "1" に置き換えられます）

   * "SECOND = auto(), -2" は動作します（auto は "2" に置き換えられる
     ため、 "SECOND" 列挙型のメンバーには "2, -2" が使用されます）

   * "THREE = [auto(), -3]" は動作 *しません* （enumメンバー "THREE"
     の作成に "<auto instance>, -3" が使用されます）

   バージョン 3.11.1 で変更: 以前のバージョンでは、 "auto()" は、代入
   行に他のものがあると正しく動作しませんでした。

   "_generate_next_value_" は、 *auto* が使用する値をカスタマイズする
   ためにオーバーライドすることができる。

   注釈:

     3.13では、デフォルトの "_generate_next_value_" は常に最も高いメン
     バーの値に1を加えたものを返し、メンバーのいずれかが比較できない型
     である場合には失敗します。

@enum.property

   A decorator similar to the built-in *property*, but specifically
   for enumerations.  It allows member attributes to have the same
   names as members themselves.

   注釈:

     the *property* and the member must be defined in separate
     classes; for example, the *value* and *name* attributes are
     defined in the *Enum* class, and *Enum* subclasses can define
     members with the names "value" and "name".

   バージョン 3.11 で追加.

@enum.unique

   列挙型専用の "class" デコレーターです。列挙型の "__members__" に別
   名がないかどうか検索します; 見つかった場合、"ValueError" が詳細情報
   とともに送出されます:

      >>> from enum import Enum, unique
      >>> @unique
      ... class Mistake(Enum):
      ...     ONE = 1
      ...     TWO = 2
      ...     THREE = 3
      ...     FOUR = 3
      ...
      Traceback (most recent call last):
      ...
      ValueError: duplicate values found in <enum 'Mistake'>: FOUR -> THREE

@enum.verify

   列挙型専用の "class" デコレーターです。対象の列挙型に対してチェック
   を行う制約の指定には "EnumCheck" のメンバーが使用されます。

   バージョン 3.11 で追加.

@enum.member

   列挙型で使用するデコレータ: 対象は列挙型のメンバー になります。

   バージョン 3.11 で追加.

@enum.nonmember

   列挙型で使用するデコレータ: 対象は列挙型のメンバー になりません。

   バージョン 3.11 で追加.

@enum.global_enum

   A decorator to change the "str()" and "repr()" of an enum to show
   its members as belonging to the module instead of its class. Should
   only be used when the enum members are exported to the module
   global namespace (see "re.RegexFlag" for an example).

   バージョン 3.11 で追加.

enum.show_flag_values(value)

   フラグの *value* に含まれる全ての2の累乗の整数のリストを返します。

   バージョン 3.11 で追加.

======================================================================


注釈
====

"IntEnum" 、 "StrEnum" 、 "IntFlag"

   これらの3つの列挙型は、既存の整数ベースおよび文字列ベースの値の代替
   として設計されています。そのため、追加の制限があります:

   * "__str__" は、列挙型のメンバーの名前ではなく値を使用します

   * "__format__" は "__str__" を使用するため、列挙型のメンバーの名前
     ではなく値を使用します

   もし、そのような制限が必要でない/望まない場合は、"int" または "str"
   タイプを継承して、カスタムの基底クラスを作成することができます:

      >>> from enum import Enum
      >>> class MyIntEnum(int, Enum):
      ...     pass

   または列挙型の中で適切な "str()" などを再代入することもできます:

      >>> from enum import Enum, IntEnum
      >>> class MyIntEnum(IntEnum):
      ...     __str__ = Enum.__str__
