Skip to content

Commit fd84e42

Browse files
nachocabilovelinux
andauthored
improve the example
Co-authored-by: Antonio Spadaro <[email protected]>
1 parent ac3aef1 commit fd84e42

File tree

1 file changed

+14
-9
lines changed

1 file changed

+14
-9
lines changed

Doc/library/enum.rst

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -510,15 +510,20 @@ Data Types
510510
of the enumeration.
511511

512512
>>> from enum import StrEnum
513-
>>> class Name(StrEnum):
514-
... IDENTIFIER = 'id'
515-
... PROPERTY = 'pro'
516-
... ATTRIBUTE = 'attr'
517-
...
518-
>>> Name.IDENTIFIER
519-
<Name.IDENTIFIER: 'id'>
520-
>>> str(Name.IDENTIFIER)
521-
'id'
513+
>>> class Color(StrEnum):
514+
... RED = 'r'
515+
... GREEN = 'g'
516+
... BLUE = 'b'
517+
... UNKNOWN = auto()
518+
...
519+
>>> Color.RED
520+
<Color.RED: 'r'>
521+
>>> str(Color.RED)
522+
'r'
523+
>>> Color.UNKNOWN
524+
<Color.UNKNOWN: 'unknown'>
525+
>>> str(Color.UNKNOWN)
526+
'unknown'
522527

523528
.. note::
524529

0 commit comments

Comments
 (0)