[Python-ideas] Enums

Ethan Furman ethan at stoneleaf.us
Thu Jul 28 00:10:23 CEST 2011


Ben Finney wrote:
> Barry Warsaw <barry at python.org> writes:
> 
>> Most enums (at least IME) are discrete objects that don't have a
>> natural ordering.
> 
> +1. This is an important property of an enumerated type, IMO.

In most cases I agree, but there can be exceptions.  Consider:

class StoveTemps(Enum):
     off = 0
     low = 15
     medium = 50
     high = 85

In such a case I see no issues with

     if temp < StoveTemps.medium:
         what_ever()


~Ethan~



More information about the Python-ideas mailing list