>>> Example(1).name
'one'

also see the Python docs.

Answer from Nils Werner on Stack Overflow
๐ŸŒ
Python documentation
docs.python.org โ€บ 3 โ€บ howto โ€บ enum.html
Enum HOWTO โ€” Python 3.14.3 documentation
An Enum is a set of symbolic names bound to unique values. They are similar to global variables, but they offer a more useful repr(), grouping, type-safety, and a few other features.
Discussions

Please help accessing Enum name and value
Trying it out online it just works: https://repl.it/repls/WhirlwindDizzyBlock So are you sure you aren't mixing up stuff in for example the interactive interpreter? More on reddit.com
๐ŸŒ r/learnpython
16
1
October 24, 2019
Why do Enums require you access the values with the 'value' keyword? The default behavior should return the value.
This is explained here in the docs. The idea is that the enum members are instances of the class, so that you can define properties/methods/etc. on them. To leverage this behavior, just make your enum a subclass of an additional class. The prototypical example, an IntEnum, same as your example, is shown here in the docs, and is actually built-in to the enum module. More on reddit.com
๐ŸŒ r/Python
12
3
June 4, 2018
How to get all values from python enum class? - Stack Overflow
I'm using Enum4 library to create an enum class as follows: class Color(Enum): RED = 1 BLUE = 2 I want to print [1, 2] as a list somewhere. How can I achieve this? More on stackoverflow.com
๐ŸŒ stackoverflow.com
Find enum value by enum name in string - Python - Stack Overflow
I'm struggling with Python enums. I created an enum class containing various fields: class Animal(Enum): DOG = "doggy" CAT = "cute cat" I know that I can access this enum... More on stackoverflow.com
๐ŸŒ stackoverflow.com
๐ŸŒ
Python
docs.python.org โ€บ 3 โ€บ library โ€บ enum.html
enum โ€” Support for enumerations
February 23, 2026 - By default, doesnโ€™t exist. If specified, either in the enum class definition or in a mixin class (such as int), all values given in the member assignment will be passed; e.g. >>> from enum import Enum >>> class MyIntEnum(int, Enum): ...
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ python โ€บ enum-in-python
enum in Python - GeeksforGeeks
December 11, 2025 - You can use a for loop to go through all Enum members and access each memberโ€™s name and value, making it easy to display or process them. ... from enum import Enum class Week(Enum): SUNDAY = 1 MONDAY = 2 TUESDAY = 3 WEDNESDAY = 4 for s in Week: print(s.value, "-", s)
๐ŸŒ
ArjanCodes
arjancodes.com โ€บ blog โ€บ python-enum-classes-for-managing-constants
Python Enums: Effective Constant Management Techniques | ArjanCodes
July 1, 2024 - An enum is a symbolic name for a set of values. Enums are used when we have a fixed set of related constants that make the code more readable and less error-prone. ... from enum import Enum class Color(Enum): RED = 1 GREEN = 2 BLUE = 3 ...
๐ŸŒ
Reddit
reddit.com โ€บ r/learnpython โ€บ please help accessing enum name and value
r/learnpython on Reddit: Please help accessing Enum name and value
October 24, 2019 -

Hello all! I wanted to use some enums in a little file I was writing, and got some weird errors, so I went to the tutorial

https://docs.python.org/3/library/enum.html#programmatic-access-to-enumeration-members-and-their-attributes

and it basically says that this should print 'RED' and 1

from enum import Enum

class Color(Enum):
RED = 1
GREEN = 2
BLUE = 3

member = Color.RED
print(member.name)
print(member.value)

but printing member.name or member.value does not work -> AttributeError: 'int' object has no attribute 'value'

What am I missing?

Find elsewhere
๐ŸŒ
Real Python
realpython.com โ€บ python-enum
Build Enumerations of Constants With Python's Enum โ€“ Real Python
December 15, 2024 - However, in Python, the values of members can be of any type, including user-defined types. For example, hereโ€™s an enumeration of school grades that uses non-consecutive numeric values in descending order: ... >>> from enum import Enum >>> class Grade(Enum): ...
๐ŸŒ
Pecar
blog.pecar.me โ€บ python-enum
Enum with `str` or `int` Mixin Breaking Change in Python 3.11 | Anลพe's Blog
December 21, 2022 - In the cases above Foo(str, Enum) behaves the same as Foo(Enum). So how can we avoid writing .value everywhere? Luckily, there is a solution for this in Python 3.11. The newly added StrEnum class! Now we can write: from enum import StrEnum class Foo(StrEnum): BAR = "bar"
๐ŸŒ
Mimo
mimo.org โ€บ glossary โ€บ python โ€บ enum
Python enum: simplify code with easy-to-read enumerations
Enums can help define constant values that remain unchanged throughout the execution of the program. You can define an enum by creating a subclass of Enum with class attributes. Since the Enum class belongs to the enum module, you need to import the module at the top of your Python script. ... from enum import Enum class Day(Enum): MONDAY = 1 TUESDAY = 2 WEDNESDAY = 3 THURSDAY = 4 FRIDAY = 5 SATURDAY = 6 SUNDAY = 7
๐ŸŒ
KDnuggets
kdnuggets.com โ€บ python-enum-how-to-build-enumerations-in-python
Python Enum: How To Build Enumerations in Python - KDnuggets
Or you access them by value, like TaskStatus(0). Now that weโ€™ve created a simple TaskStatus enum, let's learn how to perform simple tasks such as iterating over the enum members. In Python, you can work with enums pretty much the same way you work with any iterable.
๐ŸŒ
Bobby Hadz
bobbyhadz.com โ€บ blog โ€บ python-enum-get-name-by-value
Getting Names and Values of an Enum in Python | bobbyhadz
April 8, 2024 - To get an enum name by value, pass the value to the enumeration class and access the `name` attribute, e.g. `Sizes(1).name`.
๐ŸŒ
Reddit
reddit.com โ€บ r/python โ€บ why do enums require you access the values with the 'value' keyword? the default behavior should return the value.
r/Python on Reddit: Why do Enums require you access the values with the 'value' keyword? The default behavior should return the value.
June 4, 2018 -

If I define enum:

from enum import Enum
class Enum1(Enum):
      A = 1
      B = 2
      C = 3

and then do:

a = Enum1.A
print(a)

You get:

<Enum.A: 1>

Instead you need to do:

 a = Enum1.A.value
 print(a)

To print '1'.

Why is the default behavior of 'Enum1.A' not to return the value like it is for C#, Java, and C++? This just forces me to add 6 extra characters and makes accessing enum values look uglier. It is especially problematic if I am accessing multiple enum elements on the same line, which happens if I am using enums to organize a datatable.

๐ŸŒ
TutorialsPoint
tutorialspoint.com โ€บ python-program-to-lookup-enum-by-string-value
Python Program to Lookup enum by String value
April 17, 2023 - To look up an enum by string value we need to follow the following steps: ... Create a function that takes an enum string as input and returns the corresponding enum value. from enum import Enum class ClassName(Enum): Key_1= Value_1 Key_2= Value_2 Key_3= Value_3
๐ŸŒ
Cosmicpython
cosmicpython.com โ€บ blog โ€บ 2020-10-27-i-hate-enums.html
Making Enums (as always, arguably) more Pythonic
October 27, 2020 - class BRAIN(str, Enum): SMALL = 'small' MEDIUM = 'medium' GALAXY = 'galaxy' def __str__(self) -> str: return str.__str__(self) this basically avoids the need to use .value anywhere at all in your code
๐ŸŒ
YouTube
youtube.com โ€บ carberra
Enums in Python are SIMPLE but POWERFUL - YouTube
Enums, or enumerators, are a very easy way to add structure, choice, or state into your program. There are many different types to use in different situation...
Published ย  November 4, 2024
Views ย  7K
๐ŸŒ
3D Bay
clouddevs.com โ€บ home โ€บ python guides โ€บ enumeration definition with python enum type
Python Enums - Enumeration Types
October 26, 2023 - To define an Enumeration in Python, you need to use the enum module, which is part of the standard library. Here is an example of how to define an Enumeration: from enum import Enum class Color(Enum): RED = 1 GREEN = 2 BLUE = 3 ยท In this example, we have defined an Enumeration called Color with three values...
๐ŸŒ
Python
docs.python.org โ€บ 3.10 โ€บ library โ€บ enum.html
enum โ€” Support for enumerations โ€” Python 3.10.20 documentation
THREE = 3 ... FOUR = 3 ... Traceback (most recent call last): ... ValueError: duplicate values found in <enum 'Mistake'>: FOUR -> THREE ยท If the exact value is unimportant you can use auto: >>> from enum import Enum, auto >>> class Color(Enum): ... RED = auto() ...