best way to have enum-like identifiers?
Ben Finney
bignose+hates-spam at benfinney.id.au
Wed Mar 12 02:00:34 EDT 2008
mh at pixar.com writes:
> Currently I'm just putting this at the top of the file:
>
> py=1
> funcpre=2
> funcpost=3
> ...
Slightly better is:
py = object()
funcpre = object()
funcpost = object()
Thus, those names are all bound to unique objects, that won't be
unexpectedly duplicated by some other value.
> but I'm curious if there's a better way of doing this, some kind of
> enum-like thing or somesuch.
Please try the 'enum' package in the Cheeseshop:
<URL:http://pypi.python.org/pypi/enum>
--
\ “When a well-packaged web of lies has been sold to the masses |
`\ over generations, the truth will seem utterly preposterous and |
_o__) its speaker a raving lunatic.” —Dresden James |
Ben Finney
More information about the Python-list
mailing list