[Python-ideas] adopt an enum type for the standard library?
Mathias Panzenböck
grosser.meister.morti at gmx.net
Sat Apr 12 22:11:16 CEST 2008
Mark Summerfield schrieb:
>
> This is the kind of thing I'm looking for:
>
> flags = Enum("OK", "ERROR", "OTHER") # defaults to sequential ints
> flags.OK == 0
> flags.ERROR == 1
> flags.OTHER == 2
> flags.OK = 5 # exception raised
> flags.FOO # exception raised
> str(flags.OK) == "OK"
>
I once wrote this:
http://twoday.tuwien.ac.at/pub/files/enum
I don't know how good this is, though.
-panzi
More information about the Python-ideas
mailing list