<p>I've been using a small class to emulate Enums in some Python projects. Is there a better way or does this make the most sense for some situations?</p>

<p>Class code here:</p>

<pre><code>class Enum(object):
'''Simple Enum Class
Example Usage:
&gt;&gt;&gt; codes = Enum('FOO BAR BAZ') # codes.BAZ will be 2 and so on ...'''
def __init__(self, names):
    for number, name in enumerate(names.split()):
        setattr(self, name, number)
</code></pre>

Enums have been proposed for inclusion into the language before, but were rejected (see
http://www.python.org/dev/peps/pep-0354/
), though there are existing packages you could use instead of writing your own implementation:
enum:
http://pypi.python.org/pypi/enum
SymbolType (not quite the same as enums, but still useful):
http://pypi.python.org/pypi/SymbolType
Or just do a search