[Python-ideas] Optional static typing -- the crossroads
Guido van Rossum
guido at python.org
Fri Aug 15 21:31:26 CEST 2014
On Fri, Aug 15, 2014 at 12:06 PM, Ethan Furman <ethan at stoneleaf.us> wrote:
> On 08/15/2014 11:56 AM, Ryan Hiebert wrote:
>
>>
>> Getting an item from a class has no meaning for any classes that I’ve
>> ever used, and I haven’t come up with any hypothetical one that would want
>> to do that.
>>
>
> --> class Foo(Enum):
> ... spam = 'meat flavored'
> ... eggs = 'chicken by-product'
> ...
> --> Foo
> <enum 'Foo'>
>
> --> Foo['spam']
> <Foo.spam: 'meat flavored'>
>
That's a little unfortunate, but I don't think it's harmful, as I don't
expect a use case for parametrized enums. :-)
--
--Guido van Rossum (python.org/~guido)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20140815/3bc2c9f2/attachment.html>
More information about the Python-ideas
mailing list