[Python-ideas] Optional static typing -- the crossroads

Ryan Hiebert ryan at ryanhiebert.com
Fri Aug 15 21:24:09 CEST 2014


> On Aug 15, 2014, at 2: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’>

Well thanks for that ;-)

I don’t think it would conflict in this case, since I don’t think there’d be a reason to mix Enum item access with Type item access. Especially because the Enum itself might be used in the type signature (though not item access on the Enum, I’d think).

I think it’s enough of an edge-case that I still like the parallel it provides, but I appreciate the reality check.



More information about the Python-ideas mailing list