[Python-Dev] PEP 435 -- Adding an Enum type to the Python standard library (original) (raw)

Eli Bendersky eliben at gmail.com
Thu Apr 25 15:03:05 CEST 2013


On Thu, Apr 25, 2013 at 5:29 AM, Antoine Pitrou <solipsis at pitrou.net> wrote:

Le Thu, 25 Apr 2013 05:21:50 -0700, Eli Bendersky <eliben at gmail.com> a écrit : > > > > or: > > > > >>> Colors(1) > > <EnumValue: Colors.red [value=1]> > > > > > This syntax was considered initially but then rejected because it's > confusing, and there already exists a way to lookup by value > (Colors[1]).

Well, it works in latest flufl.enum. Is there a difference between the PEP and the implementation.

It produces a deprecation warning in flufl.enum because flufl.enum specifically supported this earlier. It should not be supported in the stdlib implementation.

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).

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



More information about the Python-Dev mailing list