[Python-ideas] adopt an enum type for the standard library?

Guilherme Polo ggpolo at gmail.com
Sat Apr 12 22:30:40 CEST 2008


2008/4/12, Mathias Panzenböck <grosser.meister.morti at gmx.net>:
> 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
>

Also:

http://norvig.com/python-iaq.html
http://www.python.org/doc/essays/metaclasses/Enum.py
http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/67107
http://www.faqts.com/knowledge_base/view.phtml/aid/4415

>  I don't know how good this is, though.
>
>         -panzi
>  _______________________________________________
>  Python-ideas mailing list
>  Python-ideas at python.org
>  http://mail.python.org/mailman/listinfo/python-ideas
>


-- 
-- Guilherme H. Polo Goncalves



More information about the Python-ideas mailing list