Skip to content

Commit 7683e6e

Browse files
committed
refactor: change example
1 parent 74cbdcc commit 7683e6e

File tree

1 file changed

+8
-9
lines changed

1 file changed

+8
-9
lines changed

Doc/library/enum.rst

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -35,17 +35,16 @@ An enumeration:
3535
Enumerations are created either by using :keyword:`class` syntax, or by
3636
using function-call syntax::
3737

38-
from enum import Enum
38+
>>> from enum import Enum
3939

40+
>>> # class syntax
41+
>>> class Color(Enum):
42+
... RED = 1
43+
... GREEN = 2
44+
... BLUE = 3
4045

41-
class Color(Enum):
42-
RED = '#FF0000'
43-
GREEN = 65280
44-
BLUE = '#0000FF'
45-
46-
47-
# functional syntax
48-
Color = Enum('Color', [('RED', '#FF0000'), ('GREEN', 65280), ('BLUE', '#0000FF')])
46+
>>> # functional syntax
47+
>>> Color = Enum('Color', [('RED', 1), ('GREEN', 2), ('BLUE', 3)])
4948

5049
Even though we can use :keyword:`class` syntax to create Enums, Enums
5150
are not normal Python classes. See

0 commit comments

Comments
 (0)