No no.
I mean, you could do something like this:
def some_behavior(self):
return {Bar.happy: some_function
Bar.sad: some_other_function}[self](arguments?)
Or like this:
def some_behavior(self):
custom_thing = {Bar.happy: some_function
Bar.sad: some_other_function}[self]
custom_thing()
some_function .. , , ( , ). , , , ( functools.partial ).
, - :
class Foo(Enum):
happy = 1
sad = 2
def happy_behavior():
self = Foo.happy
...
def sad_behavior():
self = Foo.sad
...
Foo.happy.some_behavior = happy_behavior
Foo.sad.some_behavior = sad_behavior
, , , Foo(1).some_behavior() Foo['sad'].some_behavior(). , / .