# 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.12\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2023-08-23 00:03+0000\n" "PO-Revision-Date: 2023-09-04 13:48+0800\n" "Last-Translator: Adrian Liaw \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 `" msgstr ":ref:`基本教學 `" #: ../../library/enum.rst:22 msgid ":ref:`Advanced Tutorial `" msgstr ":ref:`進階教學 `" #: ../../library/enum.rst:23 msgid ":ref:`Enum Cookbook `" msgstr ":ref:`列舉指南 `" #: ../../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: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? ` for more details." msgstr "" "雖然我們可以用 :keyword:`class` 語法來建立列舉,列舉並不是標準的 Python 類" "別。參考\\ :ref:`列舉有何差異 `\\ 以取得更多細節。" #: ../../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` 的子類別。(`備註 " "`_)" #: ../../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` 的子類別。(`備註 " "`_)" #: ../../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` 的子類別。(`" "備註 `_)" #: ../../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() ` of the mixed-in type." msgstr "" "由 :class:`IntEnum`、:class:`StrEnum` 及 :class:`IntFlag` 所使用來保留這些混" "合類型的 :class:`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:`auto`" msgstr ":class:`auto`" #: ../../library/enum.rst:115 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:119 msgid ":func:`~enum.property`" msgstr ":func:`~enum.property`" #: ../../library/enum.rst:121 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:125 msgid ":func:`unique`" msgstr ":func:`unique`" #: ../../library/enum.rst:127 msgid "" "Enum class decorator that ensures only one name is bound to any one value." msgstr "Enum 類別的裝飾器,用來確保任何值只有綁定到一個名稱上。" #: ../../library/enum.rst:129 msgid ":func:`verify`" msgstr ":func:`verify`" #: ../../library/enum.rst:131 msgid "" "Enum class decorator that checks user-selectable constraints on an " "enumeration." msgstr "Enum 類別的裝飾器,用來檢查列舉上使用者所選的限制。" #: ../../library/enum.rst:134 msgid ":func:`member`" msgstr ":func:`member`" #: ../../library/enum.rst:136 msgid "Make ``obj`` a member. Can be used as a decorator." msgstr "讓 ``obj`` 變成成員。可以當作裝飾器使用。" #: ../../library/enum.rst:138 msgid ":func:`nonmember`" msgstr ":func:`nonmember`" #: ../../library/enum.rst:140 msgid "Do not make ``obj`` a member. Can be used as a decorator." msgstr "不讓 ``obj`` 變成成員。可以當作裝飾器使用。" #: ../../library/enum.rst:142 msgid ":func:`global_enum`" msgstr ":func:`global_enum`" #: ../../library/enum.rst:144 msgid "" "Modify the :class:`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() ` 及 :func:`repr` ,讓成員顯示為屬於模組而不" "是類別,並將該列舉成員匯出到全域命名空間。" #: ../../library/enum.rst:148 msgid ":func:`show_flag_values`" msgstr ":func:`show_flag_values`" #: ../../library/enum.rst:150 msgid "Return a list of all power-of-two integers contained in a flag." msgstr "回傳旗標 (flag) 裡包含的所有 2 的次方的整數串列。" #: ../../library/enum.rst:153 msgid "``Flag``, ``IntFlag``, ``auto``" msgstr "``Flag``, ``IntFlag``, ``auto``" #: ../../library/enum.rst:154 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 "Data Types" msgstr "資料型別" #: ../../library/enum.rst:164 msgid "" "*EnumType* is the :term:`metaclass` for *enum* enumerations. It is possible " "to subclass *EnumType* -- see :ref:`Subclassing EnumType ` for details." msgstr "" "*EnumType* 是\\ *列舉*\\ 的 :term:`metaclass`。*EnumType* 可以有子類別 -- 細" "節請參考 :ref:`建立 EnumType 的子類別 `。" #: ../../library/enum.rst:168 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:175 msgid "This method is called in two different ways:" msgstr "這個方法可以用兩種不同的方式呼叫:" #: ../../library/enum.rst:177 msgid "to look up an existing member:" msgstr "查詢已存在的成員:" #: ../../library/enum.rst:0 msgid "cls" msgstr "cls" #: ../../library/enum.rst:179 ../../library/enum.rst:185 msgid "The enum class being called." msgstr "所呼叫的列舉類別。" #: ../../library/enum.rst:0 msgid "value" msgstr "value" #: ../../library/enum.rst:180 msgid "The value to lookup." msgstr "要查詢的值。" #: ../../library/enum.rst:182 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:186 msgid "The name of the new Enum to create." msgstr "要建立的新列舉的名稱。" #: ../../library/enum.rst:0 msgid "names" msgstr "names" #: ../../library/enum.rst:187 msgid "The names/values of the members for the new Enum." msgstr "新列舉的成員的名稱/值。" #: ../../library/enum.rst:0 msgid "module" msgstr "module" #: ../../library/enum.rst:188 msgid "The name of the module the new Enum is created in." msgstr "新列舉要建立在哪個模組名稱下。" #: ../../library/enum.rst:0 msgid "qualname" msgstr "qualname" #: ../../library/enum.rst:189 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:190 msgid "A mix-in type for the new Enum." msgstr "新列舉的混合類型。" #: ../../library/enum.rst:0 msgid "start" msgstr "start" #: ../../library/enum.rst:191 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:192 msgid "" "How to handle out-of-range values from bit operations (:class:`Flag` only)." msgstr "在位元操作時怎麼處理不在範圍內的值(只有 :class:`Flag` 會用到)" #: ../../library/enum.rst:196 msgid "Returns ``True`` if member belongs to the ``cls``::" msgstr "如果 member 屬於 ``cls`` 則回傳 ``True``: ::" #: ../../library/enum.rst:204 msgid "" "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." msgstr "" "在 Python 3.12 中這可以檢查成員的值,而不只是檢查成員;在此之前,如果用非列舉" "成員做屬於檢查會引發 ``TypeError``。" #: ../../library/enum.rst:210 msgid "" "Returns ``['__class__', '__doc__', '__members__', '__module__']`` and the " "names of the members in *cls*::" msgstr "" "回傳 ``['__class__', '__doc__', '__members__', '__module__']`` 及 *cls* 的成" "員名稱: ::" #: ../../library/enum.rst:218 msgid "" "Returns the Enum member in *cls* matching *name*, or raises a :exc:" "`KeyError`::" msgstr "回傳 *cls* 中符合 *name* 的列舉成員,或引發 :exc:`KeyError`: ::" #: ../../library/enum.rst:225 msgid "Returns each member in *cls* in definition order::" msgstr "以定義的順序回傳在 *cls* 中的每個成員: ::" #: ../../library/enum.rst:232 msgid "Returns the number of member in *cls*::" msgstr "回傳 *cls* 的成員數量: ::" #: ../../library/enum.rst:239 msgid "Returns each member in *cls* in reverse definition order::" msgstr "以跟定義相反的順序回傳 *cls* 的每個成員: ::" #: ../../library/enum.rst:246 msgid "Before 3.11 ``enum`` used ``EnumMeta`` type, which is kept as an alias." msgstr "" "在 3.11 之前,``enum`` 使用 ``EnumMeta`` 類型,目前保留此類型當作別名。" #: ../../library/enum.rst:251 msgid "*Enum* is the base class for all *enum* enumerations." msgstr "*Enum* 是所有 *enum* 列舉的基礎類別。" #: ../../library/enum.rst:255 msgid "The name used to define the ``Enum`` member::" msgstr "用來定義 ``Enum`` 成員的名稱: ::" #: ../../library/enum.rst:262 msgid "The value given to the ``Enum`` member::" msgstr "``Enum`` 成員給定的值: ::" #: ../../library/enum.rst:267 msgid "Enum member values" msgstr "列舉成員的值" #: ../../library/enum.rst:269 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:276 msgid "" "``_ignore_`` is only used during creation and is removed from the " "enumeration once creation is complete." msgstr "``_ignore_`` 只有在建立的時候用到,在列舉建立完成後會被移除。" #: ../../library/enum.rst:279 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 ` for an example." msgstr "" "``_ignore_`` 是一個不會變成成員的名稱串列,在列舉建立完成後其名稱會被移除。範" "例請參考 :ref:`TimePeriod `。" #: ../../library/enum.rst:285 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:0 msgid "name" msgstr "name" #: ../../library/enum.rst:306 msgid "The name of the member being defined (e.g. 'RED')." msgstr "定義的成員名稱(例如 'RED')。" #: ../../library/enum.rst:307 msgid "The start value for the Enum; the default is 1." msgstr "列舉的開始值,預設為 1。" #: ../../library/enum.rst:0 msgid "count" msgstr "count" #: ../../library/enum.rst:308 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:309 msgid "A list of the previous values." msgstr "一個之前值的串列。" #: ../../library/enum.rst:311 msgid "" "A *staticmethod* that is used to determine the next value returned by :class:" "`auto`::" msgstr "一個 *staticmethod*,用來決定 :class:`auto` 下一個要回傳的值的: ::" #: ../../library/enum.rst:327 msgid "" "A *classmethod* that is used to further configure subsequent subclasses. By " "default, does nothing." msgstr "一個 *classmethod*,用來進一步設定後續的子類別,預設不做任何事。" #: ../../library/enum.rst:332 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:354 msgid "" "Returns the string used for *repr()* calls. By default, returns the *Enum* " "name, member name, and value, but can be overridden::" msgstr "" #: ../../library/enum.rst:370 msgid "" "Returns the string used for *str()* calls. By default, returns the *Enum* " "name and member name, but can be overridden::" msgstr "" #: ../../library/enum.rst:385 msgid "" "Returns the string used for *format()* and *f-string* calls. By default, " "returns :meth:`__str__` return value, but can be overridden::" msgstr "" #: ../../library/enum.rst:400 msgid "" "Using :class:`auto` with :class:`Enum` results in integers of increasing " "value, starting with ``1``." msgstr "" #: ../../library/enum.rst:403 msgid "Added :ref:`enum-dataclass-support`" msgstr "新增 :ref:`enum-dataclass-support`" #: ../../library/enum.rst:408 msgid "" "*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." msgstr "" #: ../../library/enum.rst:429 msgid "" "Using :class:`auto` with :class:`IntEnum` results in integers of increasing " "value, starting with ``1``." msgstr "" #: ../../library/enum.rst:432 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 "" #: ../../library/enum.rst:439 msgid "" "*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." msgstr "" #: ../../library/enum.rst:445 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 "" #: ../../library/enum.rst:452 msgid "" "Using :class:`auto` with :class:`StrEnum` results in the lower-cased member " "name as the value." msgstr "" #: ../../library/enum.rst:457 msgid "" ":meth:`~object.__str__` is :meth:`!str.__str__` to better support the " "*replacement of existing constants* use-case. :meth:`~object.__format__` is " "likewise :meth:`!str.__format__` for that same reason." msgstr "" #: ../../library/enum.rst:465 msgid "" "*Flag* members support the bitwise operators ``&`` (*AND*), ``|`` (*OR*), " "``^`` (*XOR*), and ``~`` (*INVERT*); the results of those operators are " "members of the enumeration." msgstr "" #: ../../library/enum.rst:471 msgid "Returns *True* if value is in self::" msgstr "" #: ../../library/enum.rst:492 msgid "Returns all contained non-alias members::" msgstr "" #: ../../library/enum.rst:501 msgid "Aliases are no longer returned during iteration." msgstr "" #: ../../library/enum.rst:505 msgid "Returns number of members in flag::" msgstr "" #: ../../library/enum.rst:514 msgid "Returns *True* if any members in flag, *False* otherwise::" msgstr "" #: ../../library/enum.rst:526 msgid "Returns current flag binary or'ed with other::" msgstr "" #: ../../library/enum.rst:533 msgid "Returns current flag binary and'ed with other::" msgstr "" #: ../../library/enum.rst:542 msgid "Returns current flag binary xor'ed with other::" msgstr "" #: ../../library/enum.rst:551 msgid "Returns all the flags in *type(self)* that are not in self::" msgstr "" #: ../../library/enum.rst:562 msgid "" "Function used to format any remaining unnamed numeric values. Default is " "the value's repr; common choices are :func:`hex` and :func:`oct`." msgstr "" #: ../../library/enum.rst:567 msgid "" "Using :class:`auto` with :class:`Flag` results in integers that are powers " "of two, starting with ``1``." msgstr "" #: ../../library/enum.rst:570 msgid "The *repr()* of zero-valued flags has changed. It is now::" msgstr "" #: ../../library/enum.rst:578 msgid "" "*IntFlag* is the same as *Flag*, but its members are also integers and can " "be used anywhere that an integer can be used." msgstr "" #: ../../library/enum.rst:592 msgid "" "If any integer operation is performed with an *IntFlag* member, the result " "is not an *IntFlag*::" msgstr "" #: ../../library/enum.rst:598 msgid "If a *Flag* operation is performed with an *IntFlag* member and:" msgstr "" #: ../../library/enum.rst:600 msgid "the result is a valid *IntFlag*: an *IntFlag* is returned" msgstr "" #: ../../library/enum.rst:601 msgid "" "the result is not a valid *IntFlag*: the result depends on the " "*FlagBoundary* setting" msgstr "" #: ../../library/enum.rst:603 msgid "The *repr()* of unnamed zero-valued flags has changed. It is now:" msgstr "" #: ../../library/enum.rst:610 msgid "" "Using :class:`auto` with :class:`IntFlag` results in integers that are " "powers of two, starting with ``1``." msgstr "" #: ../../library/enum.rst:615 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 "" #: ../../library/enum.rst:619 msgid "" "Inversion of an :class:`!IntFlag` now returns a positive value that is the " "union of all flags not in the given flag, rather than a negative value. This " "matches the existing :class:`Flag` behavior." msgstr "" #: ../../library/enum.rst:625 msgid "" ":class:`!ReprEnum` uses the :meth:`repr() ` of :class:`Enum`, " "but the :class:`str() ` of the mixed-in data type:" msgstr "" #: ../../library/enum.rst:628 msgid ":meth:`!int.__str__` for :class:`IntEnum` and :class:`IntFlag`" msgstr "" #: ../../library/enum.rst:629 msgid ":meth:`!str.__str__` for :class:`StrEnum`" msgstr "" #: ../../library/enum.rst:631 msgid "" "Inherit from :class:`!ReprEnum` to keep the :class:`str() ` / :func:" "`format` of the mixed-in data type instead of using the :class:`Enum`-" "default :meth:`str() `." msgstr "" #: ../../library/enum.rst:640 msgid "" "*EnumCheck* contains the options used by the :func:`verify` decorator to " "ensure various constraints; failed constraints result in a :exc:`ValueError`." msgstr "" #: ../../library/enum.rst:645 msgid "Ensure that each value has only one name::" msgstr "" #: ../../library/enum.rst:661 msgid "" "Ensure that there are no missing values between the lowest-valued member and " "the highest-valued member::" msgstr "" #: ../../library/enum.rst:676 msgid "" "Ensure that any flag groups/masks contain only named flags -- useful when " "values are specified instead of being generated by :func:`auto`::" msgstr "" #: ../../library/enum.rst:693 msgid "" "CONTINUOUS and NAMED_FLAGS are designed to work with integer-valued members." msgstr "" #: ../../library/enum.rst:699 msgid "" "*FlagBoundary* controls how out-of-range values are handled in *Flag* and " "its subclasses." msgstr "" #: ../../library/enum.rst:704 msgid "" "Out-of-range values cause a :exc:`ValueError` to be raised. This is the " "default for :class:`Flag`::" msgstr "" #: ../../library/enum.rst:722 msgid "" "Out-of-range values have invalid values removed, leaving a valid *Flag* " "value::" msgstr "" #: ../../library/enum.rst:736 msgid "" "Out-of-range values lose their *Flag* membership and revert to :class:`int`." msgstr "" #: ../../library/enum.rst:749 msgid "" "Out-of-range values are kept, and the *Flag* membership is kept. This is the " "default for :class:`IntFlag`::" msgstr "" #: ../../library/enum.rst:766 msgid "Supported ``__dunder__`` names" msgstr "" #: ../../library/enum.rst:768 msgid "" ":attr:`~EnumType.__members__` is a read-only ordered mapping of " "``member_name``:``member`` items. It is only available on the class." msgstr "" #: ../../library/enum.rst:771 msgid "" ":meth:`~object.__new__`, if specified, must create and return the enum " "members; it is also a very good idea to set the member's :attr:`!_value_` " "appropriately. Once all the members are created it is no longer used." msgstr "" #: ../../library/enum.rst:777 msgid "Supported ``_sunder_`` names" msgstr "" #: ../../library/enum.rst:779 msgid "``_name_`` -- name of the member" msgstr "" #: ../../library/enum.rst:780 msgid "" "``_value_`` -- value of the member; can be set / modified in ``__new__``" msgstr "" #: ../../library/enum.rst:782 msgid "" "``_missing_`` -- a lookup function used when a value is not found; may be " "overridden" msgstr "" #: ../../library/enum.rst:784 msgid "" "``_ignore_`` -- a list of names, either as a :class:`list` or a :class:" "`str`, that will not be transformed into members, and will be removed from " "the final class" msgstr "" #: ../../library/enum.rst:787 msgid "" "``_order_`` -- used in Python 2/3 code to ensure member order is consistent " "(class attribute, removed during class creation)" msgstr "" #: ../../library/enum.rst:789 msgid "" "``_generate_next_value_`` -- used to get an appropriate value for an enum " "member; may be overridden" msgstr "" #: ../../library/enum.rst:794 msgid "" "For standard :class:`Enum` classes the next value chosen is the last value " "seen incremented by one." msgstr "" #: ../../library/enum.rst:797 msgid "" "For :class:`Flag` classes the next value chosen will be the next highest " "power-of-two, regardless of the last value seen." msgstr "" #: ../../library/enum.rst:800 msgid "``_missing_``, ``_order_``, ``_generate_next_value_``" msgstr "``_missing_``\\ 、\\ ``_order_``\\ 、\\ ``_generate_next_value_``" #: ../../library/enum.rst:801 msgid "``_ignore_``" msgstr "``_ignore_``" #: ../../library/enum.rst:806 msgid "Utilities and Decorators" msgstr "" #: ../../library/enum.rst:810 msgid "" "*auto* can be used in place of a value. If used, the *Enum* machinery will " "call an *Enum*'s :meth:`~Enum._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." msgstr "" #: ../../library/enum.rst:818 msgid "" "*auto* instances are only resolved when at the top level of an assignment:" msgstr "" #: ../../library/enum.rst:820 msgid "``FIRST = auto()`` will work (auto() is replaced with ``1``);" msgstr "" #: ../../library/enum.rst:821 msgid "" "``SECOND = auto(), -2`` will work (auto is replaced with ``2``, so ``2, -2`` " "is" msgstr "" #: ../../library/enum.rst:822 msgid "used to create the ``SECOND`` enum member;" msgstr "" #: ../../library/enum.rst:823 msgid "" "``THREE = [auto(), -3]`` will *not* work (``, -3`` is used to " "create the ``THREE`` enum member)" msgstr "" #: ../../library/enum.rst:828 msgid "" "In prior versions, ``auto()`` had to be the only thing on the assignment " "line to work properly." msgstr "" #: ../../library/enum.rst:831 msgid "" "``_generate_next_value_`` can be overridden to customize the values used by " "*auto*." msgstr "" #: ../../library/enum.rst:834 msgid "" "in 3.13 the default ``_generate_next_value_`` will always return the highest " "member value incremented by 1, and will fail if any member is an " "incompatible type." msgstr "" #: ../../library/enum.rst:840 msgid "" "A decorator similar to the built-in *property*, but specifically for " "enumerations. It allows member attributes to have the same names as members " "themselves." msgstr "" #: ../../library/enum.rst:844 msgid "" "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``." msgstr "" #: ../../library/enum.rst:853 msgid "" "A :keyword:`class` decorator specifically for enumerations. It searches an " "enumeration's :attr:`~EnumType.__members__`, gathering any aliases it finds; " "if any are found :exc:`ValueError` is raised with the details::" msgstr "" #: ../../library/enum.rst:871 msgid "" "A :keyword:`class` decorator specifically for enumerations. Members from :" "class:`EnumCheck` are used to specify which constraints should be checked on " "the decorated enumeration." msgstr "" #: ../../library/enum.rst:879 msgid "A decorator for use in enums: its target will become a member." msgstr "" #: ../../library/enum.rst:885 msgid "A decorator for use in enums: its target will not become a member." msgstr "" #: ../../library/enum.rst:891 msgid "" "A decorator to change the :class:`str() ` and :func:`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 :class:`re.RegexFlag` for an example)." msgstr "" #: ../../library/enum.rst:901 msgid "Return a list of all power-of-two integers contained in a flag *value*." msgstr "" #: ../../library/enum.rst:908 msgid "Notes" msgstr "" #: ../../library/enum.rst:910 msgid ":class:`IntEnum`, :class:`StrEnum`, and :class:`IntFlag`" msgstr "" #: ../../library/enum.rst:912 msgid "" "These three enum types are designed to be drop-in replacements for existing " "integer- and string-based values; as such, they have extra limitations:" msgstr "" #: ../../library/enum.rst:915 msgid "``__str__`` uses the value and not the name of the enum member" msgstr "" #: ../../library/enum.rst:917 msgid "" "``__format__``, because it uses ``__str__``, will also use the value of the " "enum member instead of its name" msgstr "" #: ../../library/enum.rst:920 msgid "" "If you do not need/want those limitations, you can either create your own " "base class by mixing in the ``int`` or ``str`` type yourself::" msgstr "" #: ../../library/enum.rst:927 msgid "or you can reassign the appropriate :meth:`str`, etc., in your enum::" msgstr "" #~ msgid "The *start* parameter was added." #~ msgstr "新增 *start* 參數。" #~ msgid "OrderedEnum" #~ msgstr "OrderedEnum" #~ msgid "DuplicateFreeEnum" #~ msgstr "DuplicateFreeEnum" #~ msgid "TimePeriod" #~ msgstr "TimePeriod" #~ msgid "_Private__names" #~ msgstr "_Private__names"