[Python-Dev] enum discussion: can someone please summarize open issues?
ethan at stoneleaf.us
Fri May 3 01:57:39 CEST 2013
On 05/02/2013 04:43 PM, Greg Ewing wrote:
> Guido van Rossum wrote:
>> you should do some other check,
>> e.g. "if x in Color:".
> So you don't think it's important to have an easy
> way to take user input that's supposed to be a
> Color name and either return a Color or raise
> a ValueError?
I don't believe that's what he said:
> The name lookup is only relevant if you already know that you have a
> valid name of an enum in the class [...]
User input should qualify, and using getattr(EnumClass, user_input) will get you an AttributeError instead of a
ValueError if user_input is not valid, but surely you don't mind that small difference. ;)
More information about the Python-Dev