I have an Enum like so:
from enum import Enum
class Animal(Enum):
cat = 'meow'
dog = 'woof'
never_heard_of = None
def talk(self):
print(self.value)
I would like to override the __call__ method so that a call like Animal('hee-haw') returns Animals.never_heard_of or None instead of raising ValueError. I would rather avoid a try statement everytime I call the Animal.
What would be a pure Python equivalent of Enum.__call__ ?