Enums and Python

Hrvoje Niksic hniksic at iskon.hr
Wed Jun 21 08:42:36 EDT 2000


Fred Gansevles <gansevle at cs.utwente.nl> writes:

> If you use enums only as a 'conveniant way to represent values',

Is there any other way to use enums?  It certainly seems the way it's
used in C.

> class Enum:
>     def __init__(self, **kw):
>         self.__dict__.update(kw)
> 
> enum = Enum(Tag = 0, Date = 1, Ammount = 2)
> 
> print "Date-field:", enum.Date

Yummy!  Very elegant.



More information about the Python-list mailing list