[Python-Dev] PEP 435 -- Adding an Enum type to the Python standard library (original) (raw)
Glenn Linderman v+python at g.nevcal.com
Sat Apr 27 04:29:44 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 4/26/2013 6:22 PM, Greg Ewing wrote:
Guido van Rossum wrote:
If we had access to the syntax used for the definition, this would be simple: assignments define items, def statements define methods. But at run time we only see the final object resulting from the definition, Another way we could tell the difference is if the def statement used a different protocol for making bindings than assignment. Suppose a def statement used in a class body called defitem, if it exists, instead of setitem. Then the metaclass would be able to do different things for defs and assignments.
Well, some assignments could be for non-enumeration items, once you start allowing EnumItem in the list. Some method of grouping enumeration items, or grouping non-enumeration items would solve the problem.
class Color( Enum ): Enum.enumerationItems( red=1, green=2, blue=3, ) # other methods and assignments -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://mail.python.org/pipermail/python-dev/attachments/20130426/fb396d77/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 ]