My name is Ram Rachum, and I'm a software developer based in Israel, specializing in the Python programming language.

This is my personal blog. I write about technology, programming, Python, and any other thoughts that come to my mind.

I'm sometimes available for freelance work in Python and Django. My expertise is in developing a product from scratch.

GitHub profile

Personal Website

10th June 2011


Why don’t people use enum in Python?

A while ago I was introduced to the concept of enum in Java. I never programmed Java, but this looks like the solution for when you want a variable to hold a value from a limited set of possible values. What is usually done in Python is either using a string or an index number, both of which are less elegant solutions in my opinion.

Python doesn’t provide a built-in enum type, but I found a few third-party modules, out of which I chose flufl.enum as being the most promising:

This looks like a pretty good solution. A tad less native than in Java, but still much better than strings or ints.

So I wonder: Why do I never see Python code that uses flufl.enum, or any other enum package for that matter? Is there some reason not to use enums in Python? Perhaps a large portion of Python programmers are ignorant about enums, (as I was before I saw it recently?) Or perhaps people just don’t really care about making their code elegant?

Anyway I’ll try to start using flufl.enum soon. One awesome application that this could have is to make a Django EnumField (or ChoiceField or whatever you want to call it) instead of the current ugly way of making an IntegerField and defining CHOICES separately.

Tagged: planetpython

All content in this website is copyright © 1986-2015 Ram Rachum.
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License, with attribution to "Ram Rachum at" including link to
To view a copy of this license, visit: