[Python-Dev] constant/enum type in stdlib
Isaac Morland
ijmorlan at uwaterloo.ca
Tue Nov 23 18:50:31 CET 2010
On Tue, 23 Nov 2010, Antoine Pitrou wrote:
> Le mardi 23 novembre 2010 à 12:32 -0500, Isaac Morland a écrit :
>> On Tue, 23 Nov 2010, Antoine Pitrou wrote:
>>
>>> We already have a bunch of bizarrely unrelated stuff in collections
>>> (such as Callable), so we could put enum there too.
>>
>> Why not just "enum" (i.e., "from enum import [...]" or "import
>> enum.[...]")? Enumerations are one of the basic kinds of types overall
>> (speaking informally and independent of any specific language) - they
>> aren't at all exotic.
>
> Enumerations aren't a type at all (they have no distinguishing
> property).
Each enumeration is a type (well, OK, not in every language, presumably,
but certainly in many languages). The word "basic" is more important than
"types" in my sentence - the point is that an enumeration capability is a
very common one in a type system, and is very general, not specific to any
particular application.
>> And "Flat is better than nested", after all.
>
> Not when it means creating a separate module for every micro-feature.
Classes have their own keyword. I don't think it's disproportionate to
give enums a top-level module name.
Having said that, I understand we're trying to have a not-too-flat module
namespace and I can see the sense in putting it in "collections". But I
think the idea that enumerations are of very wide applicability and hence
deserve a shorter name should be seriously considered.
I'll leave it at that, except for:
Hey, how about this syntax:
enum Colors:
red = 0
green = 10
blue
(blue gets the value 11)
;-)
Isaac Morland CSCF Web Guru
DC 2554C, x36650 WWW Software Specialist
More information about the Python-Dev
mailing list