Skip to content

Commit d8ddad9

Browse files
Deploy preview for PR 1214 🛫
1 parent a64f2f3 commit d8ddad9

File tree

591 files changed

+2114
-1904
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

591 files changed

+2114
-1904
lines changed

pr-preview/pr-1214/_sources/howto/enum.rst.txt

Lines changed: 12 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -965,75 +965,16 @@ want one of them to be the value::
965965

966966

967967
Finer Points
968-
^^^^^^^^^^^^
969-
970-
Supported ``__dunder__`` names
971-
""""""""""""""""""""""""""""""
972-
973-
:attr:`~enum.EnumType.__members__` is a read-only ordered mapping of ``member_name``:``member``
974-
items. It is only available on the class.
975-
976-
:meth:`~object.__new__`, if specified, must create and return the enum members; it is
977-
also a very good idea to set the member's :attr:`~Enum._value_` appropriately. Once
978-
all the members are created it is no longer used.
979-
980-
981-
Supported ``_sunder_`` names
982-
""""""""""""""""""""""""""""
968+
------------
983969

984-
- :attr:`~Enum._name_` -- name of the member
985-
- :attr:`~Enum._value_` -- value of the member; can be set in ``__new__``
986-
- :meth:`~Enum._missing_` -- a lookup function used when a value is not found;
987-
may be overridden
988-
- :attr:`~Enum._ignore_` -- a list of names, either as a :class:`list` or a
989-
:class:`str`, that will not be transformed into members, and will be removed
990-
from the final class
991-
- :meth:`~Enum._generate_next_value_` -- used to get an appropriate value for
992-
an enum member; may be overridden
993-
- :meth:`~Enum._add_alias_` -- adds a new name as an alias to an existing
994-
member.
995-
- :meth:`~Enum._add_value_alias_` -- adds a new value as an alias to an
996-
existing member. See `MultiValueEnum`_ for an example.
970+
Supported ``__dunder__`` and ``_sunder_`` names
971+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
997972

998-
.. note::
999-
1000-
For standard :class:`Enum` classes the next value chosen is the highest
1001-
value seen incremented by one.
1002-
1003-
For :class:`Flag` classes the next value chosen will be the next highest
1004-
power-of-two.
1005-
1006-
.. versionchanged:: 3.13
1007-
Prior versions would use the last seen value instead of the highest value.
1008-
1009-
.. versionadded:: 3.6 ``_missing_``, ``_order_``, ``_generate_next_value_``
1010-
.. versionadded:: 3.7 ``_ignore_``
1011-
.. versionadded:: 3.13 ``_add_alias_``, ``_add_value_alias_``
1012-
1013-
To help keep Python 2 / Python 3 code in sync an :attr:`~Enum._order_` attribute can
1014-
be provided. It will be checked against the actual order of the enumeration
1015-
and raise an error if the two do not match::
1016-
1017-
>>> class Color(Enum):
1018-
... _order_ = 'RED GREEN BLUE'
1019-
... RED = 1
1020-
... BLUE = 3
1021-
... GREEN = 2
1022-
...
1023-
Traceback (most recent call last):
1024-
...
1025-
TypeError: member order does not match _order_:
1026-
['RED', 'BLUE', 'GREEN']
1027-
['RED', 'GREEN', 'BLUE']
1028-
1029-
.. note::
1030-
1031-
In Python 2 code the :attr:`~Enum._order_` attribute is necessary as definition
1032-
order is lost before it can be recorded.
973+
The supported ``__dunder__`` and ``_sunder_`` names can be found in the :ref:`Enum API documentation <enum-dunder-sunder>`.
1033974

1034975

1035976
_Private__names
1036-
"""""""""""""""
977+
^^^^^^^^^^^^^^^
1037978

1038979
:ref:`Private names <private-name-mangling>` are not converted to enum members,
1039980
but remain normal attributes.
@@ -1042,7 +983,7 @@ but remain normal attributes.
1042983

1043984

1044985
``Enum`` member type
1045-
""""""""""""""""""""
986+
^^^^^^^^^^^^^^^^^^^^
1046987

1047988
Enum members are instances of their enum class, and are normally accessed as
1048989
``EnumClass.member``. In certain situations, such as writing custom enum
@@ -1055,7 +996,7 @@ recommended.
1055996

1056997

1057998
Creating members that are mixed with other data types
1058-
"""""""""""""""""""""""""""""""""""""""""""""""""""""
999+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
10591000

10601001
When subclassing other data types, such as :class:`int` or :class:`str`, with
10611002
an :class:`Enum`, all values after the ``=`` are passed to that data type's
@@ -1069,7 +1010,7 @@ constructor. For example::
10691010

10701011

10711012
Boolean value of ``Enum`` classes and members
1072-
"""""""""""""""""""""""""""""""""""""""""""""
1013+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
10731014

10741015
Enum classes that are mixed with non-:class:`Enum` types (such as
10751016
:class:`int`, :class:`str`, etc.) are evaluated according to the mixed-in
@@ -1084,7 +1025,7 @@ Plain :class:`Enum` classes always evaluate as :data:`True`.
10841025

10851026

10861027
``Enum`` classes with methods
1087-
"""""""""""""""""""""""""""""
1028+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
10881029

10891030
If you give your enum subclass extra methods, like the `Planet`_
10901031
class below, those methods will show up in a :func:`dir` of the member,
@@ -1097,7 +1038,7 @@ but not of the class::
10971038

10981039

10991040
Combining members of ``Flag``
1100-
"""""""""""""""""""""""""""""
1041+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
11011042

11021043
Iterating over a combination of :class:`Flag` members will only return the members that
11031044
are comprised of a single bit::
@@ -1117,7 +1058,7 @@ are comprised of a single bit::
11171058

11181059

11191060
``Flag`` and ``IntFlag`` minutia
1120-
""""""""""""""""""""""""""""""""
1061+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
11211062

11221063
Using the following snippet for our examples::
11231064

@@ -1478,6 +1419,7 @@ alias::
14781419
behaviors as well as disallowing aliases. If the only desired change is
14791420
disallowing aliases, the :func:`unique` decorator can be used instead.
14801421

1422+
.. _multi-value-enum:
14811423

14821424
MultiValueEnum
14831425
^^^^^^^^^^^^^^^^^

pr-preview/pr-1214/_sources/library/array.rst.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,13 @@ Notes:
6363
(2)
6464
.. versionadded:: 3.13
6565

66+
.. seealso::
67+
68+
The :ref:`ctypes <ctypes-fundamental-data-types>` and
69+
:ref:`struct <format-characters>` modules,
70+
as well as third-party modules like `numpy <https://numpy.org/doc/stable/reference/arrays.interface.html#object.__array_interface__>`__,
71+
use similar -- but slightly different -- type codes.
72+
6673

6774
The actual representation of values is determined by the machine architecture
6875
(strictly speaking, by the C implementation). The actual size can be accessed

0 commit comments

Comments
 (0)