[Python-ideas] Generics Syntax

Nick Coghlan ncoghlan at gmail.com
Thu Sep 15 07:41:35 EDT 2016


On 15 September 2016 at 21:11, אלעזר <elazarg at gmail.com> wrote:
> Yes the "class A[T]:" syntax requires on the ability to express variance as
> an operator, but not the other way around.
>
> It might be an argument in favor of switching to the + syntax: to make
> possible future syntax change in class definition somewhat easier to
> swallow.

A future syntax change is very unlikely, as people encountering "class
SomeName(Generic[+T]):" for the first time can easily google "python
generic class" and hopefully find useful answers in the documentation
for typing.Generic. By contrast, "class SomeName[+T]:" would have to
be covered directly in the class statement documentation, which runs
completely counter to the notion of type hints as executable code
annotations (rather than being an unavoidable core part of the
language the way they are in statically typed languages).

Cheers,
Nick.

-- 
Nick Coghlan   |   ncoghlan at gmail.com   |   Brisbane, Australia


More information about the Python-ideas mailing list