[Python-3000] Type annotations: annotating generators

Greg Ewing greg.ewing at canterbury.ac.nz
Sun May 21 08:42:19 CEST 2006


Nick Coghlan wrote:

> Assume the following is true for a type annotation system:
>    (T,) is equivalent to tuple[T]
>    (T1, T2) is equivalent to tuple[T1, T2]
>    (T1, T2, T3) is equivalent to tuple[T1, T2, T3]
> 
> but how do I use this system to spell the 
> type annotation for a tuple of unknown length containing only T instances?

   tuple[T, ...]

There wouldn't be any () equivalent, unless ... were made
a generally-available expression, in which case you could use

   (T, ...)

--
Greg


More information about the Python-3000 mailing list