Top-rated recipes tagged "meta:requires=exceptions" and "programs" but not "observer"http://code.activestate.com/recipes/tags/meta:requires=exceptions-observer+programs/top/2001-08-23T14:57:17-07:00ActiveState Code RecipesEnums for Python (Python)
2001-08-23T14:57:17-07:00Will Warehttp://code.activestate.com/recipes/users/98156/http://code.activestate.com/recipes/67107-enums-for-python/
<p style="color: grey">
Python
recipe 67107
by <a href="/recipes/users/98156/">Will Ware</a>
(<a href="/recipes/tags/programs/">programs</a>).
</p>
<p>I once tried to give Python something like C's enums, as described
here: <a href="http://groups.google.com/groups?selm=G6qzLy.6Fo%2540world.std.com" rel="nofollow">http://groups.google.com/groups?selm=G6qzLy.6Fo%40world.std.com</a>
That approach tried to assign to a dictionary returned by the locals()
function, intending that such assignments would become class attributes.
The Tim-bot explained to me the errors of my ways. The quest for the
perfect Python enum goes on.</p>