On 04/21/2017 09:04 AM, Stephan Hoyer wrote:
On Thu, Apr 20, 2017 at 10:58 AM, Ethan Furman wrote:
I'm curious, what did you find ugly with:
class TestEnum(CallableEnum):
@enum
def hello(text):
"a pleasant greeting"
print('hello,', text)
@enum
def goodbye(text):
print('goodbye,', text)
Yeah, this is actually pretty reasonable.
For my use case, both the functions and their names are pretty long, so I
wouldn't want to write them inside the enum
class. With a decorator/function wrapper, it just gets kind of long --
especially if I only import modules as required
<https://google.github.io/styleguide/pyguide.html?showone=Imports#Imports> by
the Google style guide. So my real usage
looks more like:
class Greeting(callable_enum.Enum):
HELLO = callable_enum.Value(_greet_hello)
GOODBYE = callable_enum.Value(_greet_goodbye)
TO_PYTHON_IDEAS =callable_enum.Value(_welcome_to_python_ideas)
The large callable_enum.Value() wrappers make it harder to track what's going
on.
You have to use the complete module name? Instead of `from callable_enum
import Enum, Value`? Ouch.
--
~Ethan~
_______________________________________________
Python-ideas mailing list
[email protected]
https://mail.python.org/mailman/listinfo/python-ideas
Code of Conduct: http://python.org/psf/codeofconduct/