[Python-Dev] PEP 435 -- Adding an Enum type to the Python standard library (original) (raw)
Eli Bendersky eliben at gmail.com
Thu Apr 25 23:25:27 CEST 2013
- Previous message: [Python-Dev] PEP 435 -- Adding an Enum type to the Python standard library
- Next message: [Python-Dev] PEP 435 -- Adding an Enum type to the Python standard library
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On Thu, Apr 25, 2013 at 2:17 PM, Barry Warsaw <barry at python.org> wrote:
On Apr 25, 2013, at 01:18 PM, Ethan Furman wrote:
>> Ignore the single argument call syntax for Enums please. As Eli pointed >> out, you have getitem syntax for this and the single argument call syntax >> is deprecated. It will be removed in a future version of flufl.enum and >> need not appear in stdlib enum. TOOWTDI. > >For me, the getitem syntax on a class seems odd and the call syntax is >TOOWTDI. Not if you think of it as a lookup operation instead of an instantiation operation. It really is the former because neither syntax creates new enum item objects, it just returns an already existing one.
I think it's important to stress what this syntax is actually going to be used for. No one (I hope) is actually going to write Animals(1) or Animals[1]. They will write Animals.ant - this is what enums are for in the first place! The way I see it, this syntax is for enabling programmatic access - if you pull the value from a DB and want to convert it to an actual enum value, etc. So do we really need to have two syntaxes for this?
The call syntax already has other uses, and it's weird because:
Enum(....) -> Creates new enums Animals(....) --> accesses values ?! This is contradictory
Animals[...] to serve as a by-value lookup makes sense, though.
Eli -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://mail.python.org/pipermail/python-dev/attachments/20130425/b45eefc2/attachment.html>
- Previous message: [Python-Dev] PEP 435 -- Adding an Enum type to the Python standard library
- Next message: [Python-Dev] PEP 435 -- Adding an Enum type to the Python standard library
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]