Message324282
In a conversation with Ethan Furman (the author of the enum module) I've been informed that Enum automatically checks whether the _missing_ method has returned an instance of the correct class, and raises a TypeError if not. (Link: https://stackoverflow.com/a/52064774/1222951)
However, this simply does not happen.
```
import enum
class MyEnum(enum.Enum):
FOO = "foo"
@classmethod
def _missing_(cls, value):
return 5
print(MyEnum('bar')) # output: 5
``` |
|
Date |
User |
Action |
Args |
2018-08-28 19:37:44 | Paul Pinterits | set | recipients:
+ Paul Pinterits |
2018-08-28 19:37:44 | Paul Pinterits | set | messageid: <1535485064.24.0.56676864532.issue34536@psf.upfronthosting.co.za> |
2018-08-28 19:37:44 | Paul Pinterits | link | issue34536 messages |
2018-08-28 19:37:44 | Paul Pinterits | create | |
|