[prev in list] [next in list] [prev in thread] [next in thread]
List: python-list
Subject: Re: PEP 354: Enumerations in Python
From: Felipe Almeida Lessa <felipe.lessa () gmail ! com>
Date: 2006-03-01 2:34:21
Message-ID: 1141180461.10021.44.camel () kenshin
[Download RAW message or body]
Em Seg, 2006-02-27 Ã s 17:10 -0800, Paul Rubin escreveu:> Ben Finney \
<bignose+hates-spam@benfinney.id.au> writes:> > If an enumeration object were to be \
derived from, I would think it> > just as likely to want to have *fewer* values in \
the derived> > enumeration. Subclassing would not appear to offer a simple way to do> \
> that.> > pentium_instructions = enum('add', 'sub', 'mul', ) # etc> > \
> athlon64_instructions = enum('add64', 'sub64', # etc> \
> base_enum=pentium_instructions)> > # 386 has no floating point unit> \
> i386_instructions = enum(base_enum=pentium_instructions,> \
> remove=('addf', 'subf', 'mulf',)) # etc
Or maybe just...
i386_instructions = enum('add', 'sub', 'mul', ...) pentium_instructions = \
enum(i386_instructions, 'addf', 'subf','mulf', ...) athlon64_instructions = \
enum(pentium_instructions, 'add64','sub64', ...) myprocessor_instructions = \
enum('foo', 'bar', 'baz', ...) all_instructions = \
enum(athlon64_instructions,myprocessor_instructions)
...and it could infer from the type that it's another enum to beincluded. Also...
(i386_instructions.add == pentium_instructions.add ==athlon64_instructions.add == \
all_instructions.add) == True
...and so on.
-- "Quem excele em empregar a força militar subjulga os exércitos dosoutros povos \
sem travar batalha, toma cidades fortificadas dos outrospovos sem as atacar e \
destrói os estados dos outros povos sem lutasprolongadas. Deve lutar sob o Céu com \
o propósito primordial da'preservação'. Desse modo suas armas não se embotarão, \
e os ganhospoderão ser preservados. Essa é a estratégia para \
planejar ofensivas."
-- Sun Tzu, em "A arte da guerra"
-- 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