[Python-Dev] constant/enum type in stdlib

Isaac Morland ijmorlan at uwaterloo.ca
Wed Nov 24 00:15:03 CET 2010


On 2010年11月23日, Bill Janssen wrote:
> The main purpose of that is to be able to catch type mismatches with
> static typing, though. Seems kind of pointless for Python.

The concept can work dynamically. In fact, the flufl.enum package which 
has been discussed here makes each enumeration into a separate class so 
many of the advantages of catching type mismatches are obtained.
>> Hey, how about this syntax:
>>>> enum Colors:
>> 	red = 0
>> 	green = 10
>> 	blue
>> Why not
>> class Color:
> red = (255, 0, 0)
> green = (0, 255, 0)
> blue = (0, 0, 255)
>> Seems to handle the situation OK.

Yes, this looks almost exactly like flufl.enum syntax. In any case my 
suggestion of a new keyword was not meant to be taken seriously. If I 
ever think I have a good reason to suggest a new keyword I'll sleep on it, 
take a vacation, and then if I still think a new keyword is justified I 
will specifically disclaim any possibility of the suggestion being a joke.
Isaac Morland			CSCF Web Guru
DC 2554C, x36650		WWW Software Specialist


More information about the Python-Dev mailing list

AltStyle によって変換されたページ (->オリジナル) /