Comparisons and sorting of a numeric class....

Rustom Mody rustompmody at gmail.com
Fri Jan 23 12:22:14 EST 2015


On Friday, January 23, 2015 at 10:22:06 PM UTC+5:30, Ian wrote:
> On Fri, Jan 23, 2015 at 8:31 AM, Rustom Mody  wrote:
> > Can you tell me what of the following code does not satisfy your requirements?
> > [Needs python 3.4]
> >
> >
> >>>> from enum import IntEnum
> >>>> class B4(IntEnum):
> >         F1 = 0
> >         F2 = 0
> >         F3 = 0
> >         T  = 1
> 
> This strikes me as a potential problem:
> 
> >>> B4.F1 is B4.F2 is B4.F3
> True

Thanks for pointing that out
I saw the problem but not where/why/how

Strikes me that making enumerations is-equal rather than just
=-equal is a bit heavy-handed and unnecessary
What do you think?
[BTW Changing IntEnum to (plain) Enum does not help]



More information about the Python-list mailing list