[prev in list] [next in list] [prev in thread] [next in thread] 

List:       python-list
Subject:    Re: PEP 354: Enumerations in Python
From:       Steven Bethard <steven.bethard () gmail ! com>
Date:       2006-02-28 15:55:38
Message-ID: Q-Gdnf5k7bro75nZRVn-jA () comcast ! com
[Download RAW message or body]

Ben Finney wrote:
> This PEP specifies an enumeration data type for Python.
> 
> An enumeration is an exclusive set of symbolic names bound to
> arbitrary unique values.  Values within an enumeration can be iterated
> and compared, but the values have no inherent relationship to values
> outside the enumeration.

-1 on the proposal as-is.  I don't have many use cases for enumerations, 
and I don't think they merit appearing in the builtins.  If you put them 
in the collections module instead, I'd probably be +0.

> This allows the operation to succeed, evaluating to a boolean value::
> 
>     >>> gym_night = Weekdays.wed
>     >>> gym_night < Weekdays.mon
>     False
>     >>> gym_night < Weekdays.wed
>     False
>     >>> gym_night < Weekdays.fri
>     True
>     >>> gym_night < 23
>     False
>     >>> gym_night > 23
>     True
>     >>> gym_night > "wed"
>     True
>     >>> gym_night > Grades.B
>     True

For the few cases of enumerations that I've needed, I've never wanted 
them to be comparable with <, >, etc.  If there were two classes, say 
``collections.Enum`` and ``collections.OrderedEnum`` where only the 
latter made the enumerated items comparable, you might even get me as 
high as +0.5.  (I only care about the non-comparable one, but I 
understand that others may have a need for the comparable one.)

STeVe
-- 
http://mail.python.org/mailman/listinfo/python-list
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic