PEP 354: Enumerations in Python

Paul Rubin http
Mon Feb 27 20:10:22 EST 2006


Ben Finney <bignose+hates-spam at 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



More information about the Python-list mailing list