[Python-Dev] PEP 435 -- Adding an Enum type to the Python standard library

Eli Bendersky eliben at gmail.com
Thu Apr 25 18:34:09 CEST 2013


On Thu, Apr 25, 2013 at 8:46 AM, Ethan Furman <ethan at stoneleaf.us> wrote:

> On 04/25/2013 06:03 AM, Eli Bendersky wrote:
>
>>
>> The __call__ syntax has been repurposed for the convenience API:
>>
>> --> Animals = Enum('Animals', 'ant bee cat dog')
>> --> Animals
>>
>> <Animals {ant: 1, bee: 2, cat: 3, dog: 4}>
>> --> Animals.ant
>> <EnumValue: Animals.ant [value=1]>
>> --> Animals.ant.value
>>
>> 1
>>
>> The aforementioned deprecated syntax refers to __call__ with a single
>> arguments (the convenience API by definition
>> requires more than one).
>>
>
> I don't understand why having Enum() be the convenience function rules out
> `Animals(1)` from returning `Animals.ant`.
>

Because we already have a way to do that: Animals[1]. Why do you need two
slightly different ways to do the same? Moreover, why do you want to make
Animals.__call__ behave very differently based only on the number of args?
This seems to be un-pythonic in multiple ways.

Eli
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-dev/attachments/20130425/7493a2e8/attachment.html>


More information about the Python-Dev mailing list