Deprecate getitem access by enum value name
Bug #1167091 reported by
Barry Warsaw
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.
Changed in flufl.enum: | |
milestone: | none → 4.1 |
assignee: | nobody → Barry Warsaw (barry) |
importance: | Undecided → High |
status: | New → In Progress |
Changed in flufl.enum: | |
status: | In Progress → Fix Committed |
Changed in flufl.enum: | |
status: | Fix Committed → Won't Fix |
To post a comment you must log in.