Author Paul Pinterits
Recipients Paul Pinterits
Date 2018-08-28.19:37:44
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
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:

However, this simply does not happen.

import enum

class MyEnum(enum.Enum):
    FOO = "foo"

    def _missing_(cls, value):
        return 5

print(MyEnum('bar'))  # output: 5
Date User Action Args
2018-08-28 19:37:44Paul Pinteritssetrecipients: + Paul Pinterits
2018-08-28 19:37:44Paul Pinteritssetmessageid: <>
2018-08-28 19:37:44Paul Pinteritslinkissue34536 messages
2018-08-28 19:37:44Paul Pinteritscreate