OR and AND of EnumValues should be supported and return ints

Bug #1110501 reported by Barry Warsaw
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
flufl.enum
Won't Fix
Wishlist
Unassigned

Bug Description

From python-ideas:

class Flags(Enum):
    beautiful = 1
    fast = 2
    elegant = 4
    wonderful = 8

>>> Flags.fast | Flags.elegant
6

Returning an int from such operations is the only sensible interpretation.

Barry Warsaw (barry)
Changed in flufl.enum:
importance: Undecided → Wishlist
Barry Warsaw (barry)
Changed in flufl.enum:
milestone: none → 3.4
Revision history for this message
Barry Warsaw (barry) wrote :

from python-ideas

I prefer something like

 >>> TypeFlag.HAS_GC | TypeFlag.INT_SUBCLASS
TypeFlag.HAS_GC|INT_SUBCLASS

Revision history for this message
Barry Warsaw (barry) wrote :

This would be nice to have, but only for IntEnum values. Still, I'm un-milestoning it for the 3.4 release.

Changed in flufl.enum:
milestone: 3.4 → none
status: New → Triaged
Revision history for this message
Barry Warsaw (barry) wrote :

Of course, since IntEnums let you do all the logical operations you can already do with ints, we're just talking about having a nicer repr here. The added complexity isn't worth it.

Changed in flufl.enum:
status: Triaged → Won't Fix
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.