[Python-Dev] PEP 435 - ref impl disc 2

Ethan Furman ethan at stoneleaf.us
Sat May 11 08:02:21 CEST 2013

On 05/10/2013 10:15 PM, Glenn Linderman wrote:
> But the last few lines of demo1 demonstrate that NIE doesn't like, somehow, remember that its values, deep down under
> the covers, are really int.  And doesn't even like them when they are wrapped into IntET objects.  This may or may not
> be a bug in the current Enum implementation.

You're right, sort of.  ;)

If you do

   print( repr( NIE1.x.value ))

you'll see

   ('NIE1.x', 1)

In other words, the value of NEI.x is `('NEI1.x', 1)` and that is what you would have to pass back into NEI to get the 
enum member.

As an aside, I suspect you are doing this the hard way.  Perhaps writing your own __new__ in NIE will have better 
results (I'd try, but I gotta get some sleep! ;) .  Oh, newest code posted.


More information about the Python-Dev mailing list