Deprecate getitem access by enum value name

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

Bug Description

MyEnum[foo] can be used to access enum values by value or name. This is ambiguous:

class Fruit(Enum):
    apple = 'red'
    banana = 'yellow'
    tangerine = 'orange'
    orange = 'reddish yellow'

So what should Fruit['orange'] return?

Nick pointed out that we can use getattr() to access to get values by name, e.g.

getattr(Fruit, Fruit.orange.name) or getattr(Fruit, 'orange')

We eventually want to remove this, so now we'll deprecate it.

Barry Warsaw (barry)
Changed in flufl.enum:
milestone: none → 4.1
assignee: nobody → Barry Warsaw (barry)
importance: Undecided → High
status: New → In Progress
Barry Warsaw (barry)
Changed in flufl.enum:
status: In Progress → Fix Committed
Barry Warsaw (barry)
Changed in flufl.enum:
status: Fix Committed → 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.