Best enum-module

OlavB at yahoo.com OlavB at yahoo.com
Tue Oct 10 06:33:08 EDT 2000


 Greetings!

 I need an enum-module,  I see there are several around,
 but not well documented
 I need one that

   1. Maps constant to integers, preferable in a C-like
      way: enum color = {red=1, green, blue }.
   2. Maps from string to integer: color['red'] -> red
      (=1)
   3. Maps from integer to string: color[ red] -> 'red',
      color[ 1] -> 'red'

 In my case I would prefer to refer to the values in an
 object-oriented way, e.g. color.red instead of red.

 Perhaps I could get close to this by starting with a
 list of strings, and derive two dictionaries from it?

 Thanks!
  Olav










-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20001010/31ec1d05/attachment.html>


More information about the Python-list mailing list