[Python-ideas] Callable Enum values

Ethan Furman ethan at stoneleaf.us
Thu Apr 20 13:20:04 EDT 2017

[redirecting back to the list]

On 04/19/2017 11:15 PM, Stephan Hoyer wrote:
> Ethan and Steven,
> Thanks for your feedback on this one. I agree that it probably doesn't make sense for the standard library.
> I'm still not really happy with any of the standard approaches for choosing a function based on an enum value -- they
> all seem pretty verbose/ugly -- but clearly I'm bothered by this more than most, and the standard library is not a good
> place for novel solutions.

I'm curious, what did you find ugly with:

     class TestEnum(CallableEnum):

          def hello(text):
              "a pleasant greeting"
              print('hello,', text)

          def goodbye(text):
              print('goodbye,', text)


More information about the Python-list mailing list