10000 Fix documentation for `enum.Enum.__new__` · python/cpython@5235be8 · GitHub
[go: up one dir, main page]

Skip to content

Commit 5235be8

Browse files
author
Momo Eissenhauer
committed
Fix documentation for enum.Enum.__new__
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) - The `.. note` tag was missing a space - Fix the indent to match other note tags
1 parent ef940de commit 5235be8

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

Doc/library/enum.rst

Lines changed: 6 additions & 4 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):
405+
>>> class MyIntEnum(int, Enum):
406406
... SEVENTEEN = '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)
0