[Python-Dev] PEP 435 -- Adding an Enum type to the Python standard library (original) (raw)
Steven D'Aprano steve at pearwood.info
Sat Apr 13 04:51:43 CEST 2013
- Previous message: [Python-Dev] PEP 435 -- Adding an Enum type to the Python standard library
- Next message: [Python-Dev] PEP 435 -- Adding an Enum type to the Python standard library
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On 13/04/13 10:13, Glenn Linderman wrote:
can't define two names in the same enum to have the same value, per the PEP.
I think that's too strong a restriction. I would expect to be able to do this:
class Insect(Enum): wsap = 1 # Oops, needed for backward compatibility, do not remove. wasp = 1 # Preferred. Use this in new code. bee = 2 ant = 3
Or at the very least:
class Insect(Enum): wasp = wsap = 1 bee = 2 ant = 3
I googled on "C enum" and the very first hit includes a duplicate value:
http://msdn.microsoft.com/en-AU/library/whbyts4t%28v=vs.80%29.aspx
And two examples from asm-generic/errno.h:
#define EWOULDBLOCK EAGAIN /* Operation would block */ #define EDEADLOCK EDEADLK
What's the justification for this restriction? I have looked in the PEP, and didn't see one.
-- Steven
- Previous message: [Python-Dev] PEP 435 -- Adding an Enum type to the Python standard library
- Next message: [Python-Dev] PEP 435 -- Adding an Enum type to the Python standard library
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]