Building Enumerations With Python's enum (Overview)
Some programming languages, such as Java and C++, have built-in support for a data type calledenumerations, commonly referred to asenums. Enums enable you to create sets of logically related constants that you can access through the enumeration itself. Unlike these languages, Python doesn’t have a dedicated syntax for enums. However, the Pythonstandard library provides anenum module that offers support for enumerations through theEnum class.
If you’re familiar with enums from other languages and wish to use them in Python, or if you simply want to learn how to work with enumerations, then this video course is designed for you.
In this video course, you’ll discover how to:
- Createenumerations of constants using Python’s
Enumclass - Interact with enumerations and theirmembers in Python
- Customize enumeration classes by addingnew functionalities
- Applypractical examples to gain a deeper understanding of the benefits of using enumerations
Additionally, you’ll explore other specific enumeration types available in theenum module, such asIntEnum,IntFlag, andFlag. These specialized enums will expand your repertoire.
To get the most out of this video course, you should be familiar withobject-oriented programming andinheritance in Python.
00:00Building enumerations with Python’senum.
00:04Some programming languages such as Javaand C++ include syntaxthat supports a data type known as enumerationsor just enums.This data type allows you to create setsof semantically related constants that you can accessthrough the enumeration itself.
00:21Python doesn’t have a dedicated syntax for enums,but the Python Standard Library has anenum modulethat supports enumerations through theEnum class.
00:30If you come from a language with enumerationsand you are used to working with them,or if you just want to learn howto use enumerations in Python, then this course is for you.
00:39In this course, you’ll learn how to create enumerationsof constants using Python’sEnum class, workwith enumerations and their members in Python,customize enumeration classes with new functionalitiesand code practical examplesto understand why you would use enumerations.
00:57In addition, you’ll explore other specific enumeration typesthat live in theenum modulethat will help you create specialized enums.
01:06To follow along with this course, you should be familiarwith object-oriented programming and inheritance in Python.After finishing this course, you may wantto look deeper into these two subjects,and Real Python has you coveredwith this course on object-oriented programming,
01:22and this one on inheritance.
01:26Any code that you see running in the REPL will be usingthe bpython interpreter.This is a replacement Python interpreterthat offers a number of enhancements,including code highlighting and suggestions.
01:36But any code you see running on screen will work in thePython REPL, which is typically accessed by typingpythonorpython3 at your terminalor command line prompt. While enumerationswere introduced in Python3.4, partsof this course rely on language features introduced inPython 3.11, so you’ll need to be running that versionor later to run all of the code examples seen.
02:01So now you know what’s going to be covered.Let’s get started.
Course Contents
- Getting to Know Enumerations in Python
- Creating Enumerations With Python's enum
- Working With Enumerations in Python
- Diving Deeper Into Enumerations
- Reviewing What You've Learned

