[Python-ideas] Adding Type[C] support to PEP 484 and typing.py
Koos Zevenhoven
k7hoven at gmail.com
Fri May 13 12:45:49 EDT 2016
On Fri, May 13, 2016 at 6:29 PM, Guido van Rossum <guido at python.org> wrote:
> On Fri, May 13, 2016 at 2:56 AM, Koos Zevenhoven <k7hoven at gmail.com> wrote:
>>
>> I'm definitely busy with things that have nothing to do with that, but
>> why not SubType[C]. That's what it is, right?
>
>
> It's longer and it's not clearer.
>
I'm under the impression that you wanted someone to convince you about
a potential mistake being made in naming it 'Type', so:
I've heard people use "of" or other prepositions when reading aloud
subcripts: Type[C] could be read as "type of C" or something similar.
So, I could imagine someone forgetting or failing to realize that
there is type(C) that already means "type of C", and that giving the
runtime type of an object as a static type hint does not make a lot of
sense. I'm not sure Class[C] really solves this problem either.
Luckily I can just do SubType = typing.Type ;). To me that is clearer.
I can't argue against 'longer', since 7 characters is almost double
compared to 4.
In addition, I would not mind if a plain `SubType` without [] would be
a type hint equivalent to `type`, if that would then be desired for
consistency. (not that you would have said you would mind that
either).
-- Koos
More information about the Python-ideas
mailing list