[Python-ideas] PEP for enum library type?

Ryan Hiebert ryan at ryanhiebert.com
Thu Feb 14 06:34:53 CET 2013


On Feb 13, 2013, at 8:50 PM, Ethan Furman <ethan at stoneleaf.us> wrote:

> On 02/13/2013 05:58 PM, Ryan Hiebert wrote:
> 
>> On Feb 13, 2013, at 4:57 PM, Jan Kaliszewski <zuo at chopin.edu.pl> wrote:
>> 
>>> and maybe also:
>>> 
>>>    class Color(Enum):
>>>        # 0     1     2     3
>>>        RED, GREEN, BLUE, YELLOW, *end = seq()
>>> 
>>>    class Color(Enum):
>>>        # 3     4     5     6
>>>        RED, GREEN, BLUE, YELLOW, *end = seq(3)
>>> 
>>>    class Flag(Enum):
>>>        # 1    2    4    8    16
>>>        FOO, BAR, BAZ, BOO, SPAM, *end = flags()
>>> 
>>> (yes, it *is* possible to implement it without playing with stack frames...)
>> 
>> This suggestion interests me most. Would it require language changes for that *end stuff?
> 
> Already is, since 3.0 I believe.
> 
> http://www.python.org/dev/peps/pep-3132/

Wow, I've been missing out on a great feature. How is it able to avoid the stack frames? If I knew that, I'd love to write up an implementation.


More information about the Python-ideas mailing list