shallow focus photography of books
Photo by Kimberly Farmer on Unsplash

In a lot of projects, there are usually a lot of symbols-like constants that are used throughout the application.

They could be currency symbols, weather types, clothes sizes, etc.

The recommended way of saving and reusing them over and over again is using enums.

From the docs:

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.

Here is an example where we are preparing Enum statuses:

The numbers used to initialize these enum constants are the values associated with these enum names.

We can get the name of a variable using “.name” and we can get the value of a variable using “.value”:

We can also see the repr representation and the type of enum:


That’s it for this article. I hope you find it useful.