PEP 354: Enumerations in Python

Ben Finney bignose+hates-spam at benfinney.id.au
Wed Mar 1 02:29:20 CET 2006


Toby Dickenson <tdickenson at devmail.geminidataloggers.co.uk> writes:

> On Monday 27 February 2006 02:49, Ben Finney wrote:
>> Coercing a value from an enumeration to a ``str`` results in the
>> string that was specified for that value when constructing the
>> enumeration::
>
> That sentence seems to assume that all enumeration values will have
> been specified as strings. Thats reasonable, but your description of
> the creation of an enumeration doesnt specify that.

True; I'll need to fix the specification so that it does say that.

>> An enumerated type is created from a sequence of arguments to the
>> type's constructor::
>> 
>>     >>> Weekdays = enum('sun', 'mon', 'tue', 'wed', 'thu', 'fri', 'sat')
>>     >>> Grades = enum('A', 'B', 'C', 'D', 'F')
>
> s/arguments/strings/

s/arguments/string arguments/ :-)

-- 
 \       "Too many pieces of music finish too long after the end."  -- |
  `\                                                  Igor Stravinskey |
_o__)                                                                  |
Ben Finney



More information about the Python-list mailing list