Skip to content

Commit 48e52fe

Browse files
authored
gh-118310: Fix documentation for enum.Enum.__new__ (GH-118311)
The provided example was incorrect: - The example enum was missing the `int` mixin as implied by the context - The value of `int('1a', 16)` was incorrectly given as 17 (should be 26)
1 parent 44a9f3d commit 48e52fe

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

Doc/library/enum.rst

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -402,13 +402,15 @@ Data Types
402402
in the member assignment will be passed; e.g.
403403

404404
>>> from enum import Enum
405-
>>> class MyIntEnum(Enum):
406-
... SEVENTEEN = '1a', 16
405+
>>> class MyIntEnum(int, Enum):
406+
... TWENTYSIX = '1a', 16
407407

408-
results in the call ``int('1a', 16)`` and a value of ``17`` for the member.
408+
results in the call ``int('1a', 16)`` and a value of ``26`` for the member.
409409

410-
.. note:: When writing a custom ``__new__``, do not use ``super().__new__`` --
411-
call the appropriate ``__new__`` instead.
410+
.. note::
411+
412+
When writing a custom ``__new__``, do not use ``super().__new__`` --
413+
call the appropriate ``__new__`` instead.
412414

413415
.. method:: Enum.__repr__(self)
414416

0 commit comments

Comments
 (0)