]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
docs: add a more precise example in enum doc (GH-121015)
authorFilip "Ret2Me" Poplewski <37419029+Ret2Me@users.noreply.github.com>
Fri, 1 Nov 2024 19:28:50 +0000 (20:28 +0100)
committerGitHub <noreply@github.com>
Fri, 1 Nov 2024 19:28:50 +0000 (12:28 -0700)
* docs: add a more precise example

Previous example used manual integer value assignment in class based declaration but in functional syntax has been used auto value assignment what could be confusing for the new users. Additionally documentation doesn't show how to declare new enum via functional syntax with usage of the manual value assignment.

* docs: remove whitespace characters

* refactor: change example

---------

Co-authored-by: Ethan Furman <ethan@stoneleaf.us>
Doc/library/enum.rst

index 242b243643990380806dc1d3c12550c44684c012..16a9b0326e9f3dd3767ba593cafcb94b2be9787c 100644 (file)
@@ -44,7 +44,7 @@ using function-call syntax::
    ...     BLUE = 3
 
    >>> # functional syntax
-   >>> Color = Enum('Color', ['RED', 'GREEN', 'BLUE'])
+   >>> Color = Enum('Color', [('RED', 1), ('GREEN', 2), ('BLUE', 3)])
 
 Even though we can use :keyword:`class` syntax to create Enums, Enums
 are not normal Python classes.  See