# Python Documentation Turkish Translation # Copyright (C) 2001-2024, Python Software Foundation # This file is distributed under the same license as the Python package. # #, fuzzy msgid "" msgstr "" "Project-Id-Version: Python 3.12\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2024-11-01 00:21+0000\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: \n" "Language-Team: TURKISH \n" "Language: tr\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" #: library/enum.rst:2 msgid ":mod:`!enum` --- Support for enumerations" msgstr "" #: library/enum.rst:14 msgid "**Source code:** :source:`Lib/enum.py`" msgstr "" #: library/enum.rst:18 msgid "" "This page contains the API reference information. For tutorial information " "and discussion of more advanced topics, see" msgstr "" #: library/enum.rst:21 msgid ":ref:`Basic Tutorial `" msgstr "" #: library/enum.rst:22 msgid ":ref:`Advanced Tutorial `" msgstr "" #: library/enum.rst:23 msgid ":ref:`Enum Cookbook `" msgstr "" #: 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 "" #: library/enum.rst:32 msgid "uses *call* syntax to return members by value" msgstr "" #: library/enum.rst:33 msgid "uses *index* syntax to return members by name" msgstr "" #: library/enum.rst:35 msgid "" "Enumerations are created either by using :keyword:`class` syntax, or by " "using function-call syntax::" msgstr "" #: 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', 'GREEN', 'BLUE'])" msgstr "" #: 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 "" #: library/enum.rst:53 msgid "Nomenclature" msgstr "" #: library/enum.rst:55 msgid "The class :class:`!Color` is an *enumeration* (or *enum*)" msgstr "" #: library/enum.rst:56 msgid "" "The attributes :attr:`!Color.RED`, :attr:`!Color.GREEN`, etc., are " "*enumeration members* (or *members*) and are functionally constants." msgstr "" #: 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 "" #: library/enum.rst:65 msgid "Module Contents" msgstr "" #: library/enum.rst:67 msgid ":class:`EnumType`" msgstr "" #: library/enum.rst:69 msgid "The ``type`` for Enum and its subclasses." msgstr "" #: library/enum.rst:71 msgid ":class:`Enum`" msgstr "" #: library/enum.rst:73 msgid "Base class for creating enumerated constants." msgstr "" #: library/enum.rst:75 msgid ":class:`IntEnum`" msgstr "" #: library/enum.rst:77 msgid "" "Base class for creating enumerated constants that are also subclasses of :" "class:`int`. (`Notes`_)" msgstr "" #: library/enum.rst:80 msgid ":class:`StrEnum`" msgstr "" #: library/enum.rst:82 msgid "" "Base class for creating enumerated constants that are also subclasses of :" "class:`str`. (`Notes`_)" msgstr "" #: library/enum.rst:85 msgid ":class:`Flag`" msgstr "" #: 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 "" #: library/enum.rst:90 msgid ":class:`IntFlag`" msgstr "" #: 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 "" #: library/enum.rst:96 msgid ":class:`ReprEnum`" msgstr "" #: 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 "" #: library/enum.rst:101 msgid ":class:`EnumCheck`" msgstr "" #: 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 "" #: library/enum.rst:107 msgid ":class:`FlagBoundary`" msgstr "" #: 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 "" #: library/enum.rst:113 msgid ":class:`auto`" msgstr "" #: 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 "" #: library/enum.rst:119 msgid ":func:`~enum.property`" msgstr "" #: 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 "" #: library/enum.rst:125 msgid ":func:`unique`" msgstr "" #: library/enum.rst:127 msgid "" "Enum class decorator that ensures only one name is bound to any one value." msgstr "" #: library/enum.rst:129 msgid ":func:`verify`" msgstr "" #: library/enum.rst:131 msgid "" "Enum class decorator that checks user-selectable constraints on an " "enumeration." msgstr "" #: library/enum.rst:134 msgid ":func:`member`" msgstr "" #: library/enum.rst:136 msgid "Make ``obj`` a member. Can be used as a decorator." msgstr "" #: library/enum.rst:138 msgid ":func:`nonmember`" msgstr "" #: library/enum.rst:140 msgid "Do not make ``obj`` a member. Can be used as a decorator." msgstr "" #: library/enum.rst:142 msgid ":func:`global_enum`" msgstr "" #: 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 "" #: library/enum.rst:148 msgid ":func:`show_flag_values`" msgstr "" #: library/enum.rst:150 msgid "Return a list of all power-of-two integers contained in a flag." msgstr "" #: library/enum.rst:153 msgid "``Flag``, ``IntFlag``, ``auto``" msgstr "" #: library/enum.rst:154 msgid "" "``StrEnum``, ``EnumCheck``, ``ReprEnum``, ``FlagBoundary``, ``property``, " "``member``, ``nonmember``, ``global_enum``, ``show_flag_values``" msgstr "" #: 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 "" #: 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 "" #: 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 "" #: library/enum.rst:185 msgid "The enum class being called." msgstr "" #: library/enum.rst:0 msgid "value" msgstr "" #: 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 "" #: library/enum.rst:186 msgid "The name of the new Enum to create." msgstr "" #: library/enum.rst:0 msgid "names" msgstr "" #: library/enum.rst:187 msgid "The names/values of the members for the new Enum." msgstr "" #: library/enum.rst:0 msgid "module" msgstr "" #: library/enum.rst:188 msgid "The name of the module the new Enum is created in." msgstr "" #: library/enum.rst:0 msgid "qualname" msgstr "" #: 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 "" #: library/enum.rst:190 msgid "A mix-in type for the new Enum." msgstr "" #: library/enum.rst:0 msgid "start" msgstr "" #: library/enum.rst:191 msgid "The first integer value for the Enum (used by :class:`auto`)." msgstr "" #: library/enum.rst:0 msgid "boundary" msgstr "" #: library/enum.rst:192 msgid "" "How to handle out-of-range values from bit operations (:class:`Flag` only)." msgstr "" #: library/enum.rst:196 msgid "Returns ``True`` if member belongs to the ``cls``::" msgstr "" #: library/enum.rst:198 msgid "" ">>> some_var = Color.RED\n" ">>> some_var in Color\n" "True\n" ">>> Color.RED.value in Color\n" "True" msgstr "" #: library/enum.rst:206 msgid "" "Before Python 3.12, a ``TypeError`` is raised if a non-Enum-member is used " "in a containment check." msgstr "" #: library/enum.rst:211 msgid "" "Returns ``['__class__', '__doc__', '__members__', '__module__']`` and the " "names of the members in *cls*::" msgstr "" #: library/enum.rst:214 msgid "" ">>> dir(Color)\n" "['BLUE', 'GREEN', 'RED', '__class__', '__contains__', '__doc__', " "'__getitem__', '__init_subclass__', '__iter__', '__len__', '__members__', " "'__module__', '__name__', '__qualname__']" msgstr "" #: library/enum.rst:219 msgid "" "Returns the Enum member in *cls* matching *name*, or raises a :exc:" "`KeyError`::" msgstr "" #: library/enum.rst:221 msgid "" ">>> Color['BLUE']\n" "" msgstr "" #: library/enum.rst:226 msgid "Returns each member in *cls* in definition order::" msgstr "" #: library/enum.rst:228 msgid "" ">>> list(Color)\n" "[, , ]" msgstr "" #: library/enum.rst:233 msgid "Returns the number of member in *cls*::" msgstr "" #: library/enum.rst:235 msgid "" ">>> len(Color)\n" "3" msgstr "" #: library/enum.rst:240 msgid "Returns a mapping of every enum name to its member, including aliases" msgstr "" #: library/enum.rst:244 msgid "Returns each member in *cls* in reverse definition order::" msgstr "" #: library/enum.rst:246 msgid "" ">>> list(reversed(Color))\n" "[, , ]" msgstr "" #: library/enum.rst:251 msgid "Before 3.11 ``enum`` used ``EnumMeta`` type, which is kept as an alias." msgstr "" #: library/enum.rst:256 msgid "*Enum* is the base class for all *enum* enumerations." msgstr "" #: library/enum.rst:260 msgid "The name used to define the ``Enum`` member::" msgstr "" #: library/enum.rst:262 msgid "" ">>> Color.BLUE.name\n" "'BLUE'" msgstr "" #: library/enum.rst:267 msgid "The value given to the ``Enum`` member::" msgstr "" #: library/enum.rst:269 msgid "" ">>> Color.RED.value\n" "1" msgstr "" #: library/enum.rst:292 msgid "Value of the member, can be set in :meth:`~Enum.__new__`." msgstr "" #: library/enum.rst:274 msgid "Enum member values" msgstr "" #: library/enum.rst:276 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 "" #: library/enum.rst:281 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 "" #: library/enum.rst:288 msgid "Name of the member." msgstr "" #: library/enum.rst:296 msgid "" "No longer used, kept for backward compatibility. (class attribute, removed " "during class creation)." msgstr "" #: library/enum.rst:301 msgid "" "``_ignore_`` is only used during creation and is removed from the " "enumeration once creation is complete." msgstr "" #: library/enum.rst:304 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 "" #: library/enum.rst:310 msgid "" "Returns ``['__class__', '__doc__', '__module__', 'name', 'value']`` and any " "public methods defined on *self.__class__*::" msgstr "" #: library/enum.rst:313 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 "" #: library/enum.rst:0 msgid "name" msgstr "" #: library/enum.rst:331 msgid "The name of the member being defined (e.g. 'RED')." msgstr "" #: library/enum.rst:332 msgid "The start value for the Enum; the default is 1." msgstr "" #: library/enum.rst:0 msgid "count" msgstr "" #: library/enum.rst:333 msgid "The number of members currently defined, not including this one." msgstr "" #: library/enum.rst:0 msgid "last_values" msgstr "" #: library/enum.rst:334 msgid "A list of the previous values." msgstr "" #: library/enum.rst:336 msgid "" "A *staticmethod* that is used to determine the next value returned by :class:" "`auto`::" msgstr "" #: library/enum.rst:339 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 "" #: library/enum.rst:352 msgid "" "By default, does nothing. If multiple values are given in the member " "assignment, those values become separate arguments to ``__init__``; e.g." msgstr "" #: library/enum.rst:359 msgid "" "``Weekday.__init__()`` would be called as ``Weekday.__init__(self, 1, " "'Mon')``" msgstr "" #: library/enum.rst:363 msgid "" "A *classmethod* that is used to further configure subsequent subclasses. By " "default, does nothing." msgstr "" #: library/enum.rst:368 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 "" #: library/enum.rst:371 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" "" msgstr "" #: library/enum.rst:390 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 "" #: library/enum.rst:398 msgid "" "results in the call ``int('1a', 16)`` and a value of ``26`` for the member." msgstr "" #: library/enum.rst:402 msgid "" "When writing a custom ``__new__``, do not use ``super().__new__`` -- call " "the appropriate ``__new__`` instead." msgstr "" #: library/enum.rst:407 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:410 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 "" #: library/enum.rst:423 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:426 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" "(, 'ALTERNATE', 'ALTERNATE')" msgstr "" #: library/enum.rst:438 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:441 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', 'ALTERNATE')" msgstr "" #: library/enum.rst:453 msgid "" "Using :class:`auto` with :class:`Enum` results in integers of increasing " "value, starting with ``1``." msgstr "" #: library/enum.rst:456 msgid "Added :ref:`enum-dataclass-support`" msgstr "" #: library/enum.rst:461 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:482 msgid "" "Using :class:`auto` with :class:`IntEnum` results in integers of increasing " "value, starting with ``1``." msgstr "" #: library/enum.rst:485 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:492 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:498 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:505 msgid "" "Using :class:`auto` with :class:`StrEnum` results in the lower-cased member " "name as the value." msgstr "" #: library/enum.rst:510 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:518 msgid "" "``Flag`` is the same as :class:`Enum`, but its members support the bitwise " "operators ``&`` (*AND*), ``|`` (*OR*), ``^`` (*XOR*), and ``~`` (*INVERT*); " "the results of those operations are (aliases of) members of the enumeration." msgstr "" #: library/enum.rst:524 msgid "Returns *True* if value is in self::" msgstr "" #: library/enum.rst:526 msgid "" ">>> from enum import Flag, auto\n" ">>> class Color(Flag):\n" "... RED = auto()\n" "... GREEN = auto()\n" "... BLUE = auto()\n" "...\n" ">>> purple = Color.RED | Color.BLUE\n" ">>> white = Color.RED | Color.GREEN | Color.BLUE\n" ">>> Color.GREEN in purple\n" "False\n" ">>> Color.GREEN in white\n" "True\n" ">>> purple in white\n" "True\n" ">>> white in purple\n" "False" msgstr "" #: library/enum.rst:545 msgid "Returns all contained non-alias members::" msgstr "" #: library/enum.rst:547 msgid "" ">>> list(Color.RED)\n" "[]\n" ">>> list(purple)\n" "[, ]" msgstr "" #: library/enum.rst:556 msgid "Returns number of members in flag::" msgstr "" #: library/enum.rst:558 msgid "" ">>> len(Color.GREEN)\n" "1\n" ">>> len(white)\n" "3" msgstr "" #: library/enum.rst:567 msgid "Returns *True* if any members in flag, *False* otherwise::" msgstr "" #: library/enum.rst:569 msgid "" ">>> bool(Color.GREEN)\n" "True\n" ">>> bool(white)\n" "True\n" ">>> black = Color(0)\n" ">>> bool(black)\n" "False" msgstr "" #: library/enum.rst:579 msgid "Returns current flag binary or'ed with other::" msgstr "" #: library/enum.rst:581 msgid "" ">>> Color.RED | Color.GREEN\n" "" msgstr "" #: library/enum.rst:586 msgid "Returns current flag binary and'ed with other::" msgstr "" #: library/enum.rst:588 msgid "" ">>> purple & white\n" "\n" ">>> purple & Color.GREEN\n" "" msgstr "" #: library/enum.rst:595 msgid "Returns current flag binary xor'ed with other::" msgstr "" #: library/enum.rst:597 msgid "" ">>> purple ^ white\n" "\n" ">>> purple ^ Color.GREEN\n" "" msgstr "" #: library/enum.rst:604 msgid "Returns all the flags in *type(self)* that are not in self::" msgstr "" #: library/enum.rst:606 msgid "" ">>> ~white\n" "\n" ">>> ~purple\n" "\n" ">>> ~Color.RED\n" "" msgstr "" #: library/enum.rst:615 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:620 msgid "" "Using :class:`auto` with :class:`Flag` results in integers that are powers " "of two, starting with ``1``." msgstr "" #: library/enum.rst:623 msgid "The *repr()* of zero-valued flags has changed. It is now::" msgstr "" #: library/enum.rst:631 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:645 msgid "" "If any integer operation is performed with an *IntFlag* member, the result " "is not an *IntFlag*::" msgstr "" #: library/enum.rst:648 msgid "" ">>> Color.RED + 2\n" "3" msgstr "" #: library/enum.rst:651 msgid "If a *Flag* operation is performed with an *IntFlag* member and:" msgstr "" #: library/enum.rst:653 msgid "the result is a valid *IntFlag*: an *IntFlag* is returned" msgstr "" #: library/enum.rst:654 msgid "" "the result is not a valid *IntFlag*: the result depends on the " "*FlagBoundary* setting" msgstr "" #: library/enum.rst:656 msgid "The *repr()* of unnamed zero-valued flags has changed. It is now:" msgstr "" #: library/enum.rst:663 msgid "" "Using :class:`auto` with :class:`IntFlag` results in integers that are " "powers of two, starting with ``1``." msgstr "" #: library/enum.rst:668 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:672 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:678 msgid "" ":class:`!ReprEnum` uses the :meth:`repr() ` of :class:`Enum`, " "but the :class:`str() ` of the mixed-in data type:" msgstr "" #: library/enum.rst:681 msgid ":meth:`!int.__str__` for :class:`IntEnum` and :class:`IntFlag`" msgstr "" #: library/enum.rst:682 msgid ":meth:`!str.__str__` for :class:`StrEnum`" msgstr "" #: library/enum.rst:684 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:693 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:698 msgid "Ensure that each value has only one name::" msgstr "" #: library/enum.rst:700 msgid "" ">>> from enum import Enum, verify, UNIQUE\n" ">>> @verify(UNIQUE)\n" "... class Color(Enum):\n" "... RED = 1\n" "... GREEN = 2\n" "... BLUE = 3\n" "... CRIMSON = 1\n" "Traceback (most recent call last):\n" "...\n" "ValueError: aliases found in : CRIMSON -> RED" msgstr "" #: library/enum.rst:714 msgid "" "Ensure that there are no missing values between the lowest-valued member and " "the highest-valued member::" msgstr "" #: library/enum.rst:717 msgid "" ">>> from enum import Enum, verify, CONTINUOUS\n" ">>> @verify(CONTINUOUS)\n" "... class Color(Enum):\n" "... RED = 1\n" "... GREEN = 2\n" "... BLUE = 5\n" "Traceback (most recent call last):\n" "...\n" "ValueError: invalid enum 'Color': missing values 3, 4" msgstr "" #: library/enum.rst:729 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:732 msgid "" ">>> from enum import Flag, verify, NAMED_FLAGS\n" ">>> @verify(NAMED_FLAGS)\n" "... class Color(Flag):\n" "... RED = 1\n" "... GREEN = 2\n" "... BLUE = 4\n" "... WHITE = 15\n" "... NEON = 31\n" "Traceback (most recent call last):\n" "...\n" "ValueError: invalid Flag 'Color': aliases WHITE and NEON are missing " "combined values of 0x18 [use enum.show_flag_values(value) for details]" msgstr "" #: library/enum.rst:746 msgid "" "CONTINUOUS and NAMED_FLAGS are designed to work with integer-valued members." msgstr "" #: library/enum.rst:752 msgid "" "*FlagBoundary* controls how out-of-range values are handled in *Flag* and " "its subclasses." msgstr "" #: library/enum.rst:757 msgid "" "Out-of-range values cause a :exc:`ValueError` to be raised. This is the " "default for :class:`Flag`::" msgstr "" #: library/enum.rst:760 msgid "" ">>> from enum import Flag, STRICT, auto\n" ">>> class StrictFlag(Flag, boundary=STRICT):\n" "... RED = auto()\n" "... GREEN = auto()\n" "... BLUE = auto()\n" "...\n" ">>> StrictFlag(2**2 + 2**4)\n" "Traceback (most recent call last):\n" "...\n" "ValueError: invalid value 20\n" " given 0b0 10100\n" " allowed 0b0 00111" msgstr "" #: library/enum.rst:775 msgid "" "Out-of-range values have invalid values removed, leaving a valid *Flag* " "value::" msgstr "" #: library/enum.rst:778 msgid "" ">>> from enum import Flag, CONFORM, auto\n" ">>> class ConformFlag(Flag, boundary=CONFORM):\n" "... RED = auto()\n" "... GREEN = auto()\n" "... BLUE = auto()\n" "...\n" ">>> ConformFlag(2**2 + 2**4)\n" "" msgstr "" #: library/enum.rst:789 msgid "" "Out-of-range values lose their *Flag* membership and revert to :class:`int`." msgstr "" #: library/enum.rst:802 msgid "" "Out-of-range values are kept, and the *Flag* membership is kept. This is the " "default for :class:`IntFlag`::" msgstr "" #: library/enum.rst:805 msgid "" ">>> from enum import Flag, KEEP, auto\n" ">>> class KeepFlag(Flag, boundary=KEEP):\n" "... RED = auto()\n" "... GREEN = auto()\n" "... BLUE = auto()\n" "...\n" ">>> KeepFlag(2**2 + 2**4)\n" "" msgstr "" #: library/enum.rst:819 msgid "Supported ``__dunder__`` names" msgstr "" #: library/enum.rst:821 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:824 msgid "" ":meth:`~Enum.__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:830 msgid "Supported ``_sunder_`` names" msgstr "" #: library/enum.rst:832 msgid ":attr:`~Enum._name_` -- name of the member" msgstr "" #: library/enum.rst:833 msgid ":attr:`~Enum._value_` -- value of the member; can be set in ``__new__``" msgstr "" #: library/enum.rst:834 msgid "" ":meth:`~Enum._missing_` -- a lookup function used when a value is not found; " "may be overridden" msgstr "" #: library/enum.rst:836 msgid "" ":attr:`~Enum._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:839 msgid "" ":attr:`~Enum._order_` -- no longer used, kept for backward compatibility " "(class attribute, removed during class creation)" msgstr "" #: library/enum.rst:841 msgid "" ":meth:`~Enum._generate_next_value_` -- used to get an appropriate value for " "an enum member; may be overridden" msgstr "" #: library/enum.rst:846 msgid "" "For standard :class:`Enum` classes the next value chosen is the last value " "seen incremented by one." msgstr "" #: library/enum.rst:849 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:852 msgid "``_missing_``, ``_order_``, ``_generate_next_value_``" msgstr "" #: library/enum.rst:853 msgid "``_ignore_``" msgstr "" #: library/enum.rst:858 msgid "Utilities and Decorators" msgstr "" #: library/enum.rst:862 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:870 msgid "" "*auto* instances are only resolved when at the top level of an assignment:" msgstr "" #: library/enum.rst:872 msgid "``FIRST = auto()`` will work (auto() is replaced with ``1``);" msgstr "" #: library/enum.rst:873 msgid "" "``SECOND = auto(), -2`` will work (auto is replaced with ``2``, so ``2, -2`` " "is used to create the ``SECOND`` enum member;" msgstr "" #: library/enum.rst:875 msgid "" "``THREE = [auto(), -3]`` will *not* work (``, -3`` is used to " "create the ``THREE`` enum member)" msgstr "" #: library/enum.rst:880 msgid "" "In prior versions, ``auto()`` had to be the only thing on the assignment " "line to work properly." msgstr "" #: library/enum.rst:883 msgid "" "``_generate_next_value_`` can be overridden to customize the values used by " "*auto*." msgstr "" #: library/enum.rst:886 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:892 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:896 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:905 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:909 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 : FOUR -> THREE" msgstr "" #: library/enum.rst:923 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:931 msgid "A decorator for use in enums: its target will become a member." msgstr "" #: library/enum.rst:937 msgid "A decorator for use in enums: its target will not become a member." msgstr "" #: library/enum.rst:943 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:953 msgid "Return a list of all power-of-two integers contained in a flag *value*." msgstr "" #: library/enum.rst:960 msgid "Notes" msgstr "" #: library/enum.rst:962 msgid ":class:`IntEnum`, :class:`StrEnum`, and :class:`IntFlag`" msgstr "" #: library/enum.rst:964 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:967 msgid "``__str__`` uses the value and not the name of the enum member" msgstr "" #: library/enum.rst:969 msgid "" "``__format__``, because it uses ``__str__``, will also use the value of the " "enum member instead of its name" msgstr "" #: library/enum.rst:972 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:975 msgid "" ">>> from enum import Enum\n" ">>> class MyIntEnum(int, Enum):\n" "... pass" msgstr "" #: library/enum.rst:979 msgid "or you can reassign the appropriate :meth:`str`, etc., in your enum::" msgstr "" #: library/enum.rst:981 msgid "" ">>> from enum import Enum, IntEnum\n" ">>> class MyIntEnum(IntEnum):\n" "... __str__ = Enum.__str__" msgstr ""