diff options
author | Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> | 2024-05-07 12:02:55 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-05-07 12:02:55 (GMT) |
commit | 8e53f66797718a12bad7c6b50b93c8062d062a82 (patch) | |
tree | 957887cc46ae227eb1b0cb5c3f4d518751b6cd03 /Doc | |
parent | f85021a6a2f251883ac355a21f1ad51f7bf64fb7 (diff) | |
download | cpython-8e53f66797718a12bad7c6b50b93c8062d062a82.zip cpython-8e53f66797718a12bad7c6b50b93c8062d062a82.tar.gz cpython-8e53f66797718a12bad7c6b50b93c8062d062a82.tar.bz2 |
[3.12] gh-118310: Fix documentation for `enum.Enum.__new__` (GH-118311) (GH-118699)
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)
(cherry picked from commit 48e52fe2c9a7b33671f6b5d1420a71a6f31ad64b)
Co-authored-by: Momo Eissenhauer <mmEissen@users.noreply.github.com>
Diffstat (limited to 'Doc')
-rw-r--r-- | Doc/library/enum.rst | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/Doc/library/enum.rst b/Doc/library/enum.rst index faeb94d..18b54a4 100644 --- a/Doc/library/enum.rst +++ b/Doc/library/enum.rst @@ -392,13 +392,15 @@ Data Types in the member assignment will be passed; e.g. >>> from enum import Enum - >>> class MyIntEnum(Enum): - ... SEVENTEEN = '1a', 16 + >>> class MyIntEnum(int, Enum): + ... TWENTYSIX = '1a', 16 - results in the call ``int('1a', 16)`` and a value of ``17`` for the member. + results in the call ``int('1a', 16)`` and a value of ``26`` for the member. - .. note:: When writing a custom ``__new__``, do not use ``super().__new__`` -- - call the appropriate ``__new__`` instead. + .. note:: + + When writing a custom ``__new__``, do not use ``super().__new__`` -- + call the appropriate ``__new__`` instead. .. method:: Enum.__repr__(self) |