first of all, thanks for working on variadic generics! I look forward to them.
My question: all the examples in https://www.python.org/dev/peps/pep-0646/ unpack into variadic arguments. But can I write code like this?
``` Ts = TypeVarTuple("Ts")
def enumerate_args(f: Callable[[*Tuple[int, Ts]]], *args: *Ts): f(*enumerate(args)) ```
In particular I'm talking about the `*Tuple[int, Ts]` syntax. All the examples from the PEP use `*Ts` so I don't know if this is legal, but I hope so.
This should probably be clarified in the PEP.
I don't believe this is supported in pep 646 today. It was originally going to be supported with a Map operator. With a Map operator it would let you do something like,
T = TypeVar('T') Ts = TypeVarTuple("Ts") IndexedTuple = Tuple[Int, T]
def enumerage_args(*args: *Ts) -> *Map[IndexedTuple, Ts] return enumerate(args)
Map operator takes two arguments, a generic type and type var tuple. This document describes map operator in more detail and an older version of the pep had it.
The reason it is missing is original version of 646 was becoming too complex for a single pep. My understanding is your example/similar examples are intended for the future to be supported, but that Map operator and other extensions to variadic generics will be future peps.
Oops, sorry for the slow reply - I'm not subscribed to this mailing list.
As Mehdi2277 says, this would indeed require the Map operator we'll introduce in a future PEP.
But that's a good point about the `*Tuple[int, Ts]` syntax. I think the interpretation of it that would be most consistent with the rest of PEP 646 would actually be something slightly different than you had in mind - instead of saying that the Callable took args like
Tuple[int, Ts], Tuple[int, Ts], ...
it would say that the Callable took a variable number of arguments, the first of which was `int`, and the rest of which are bound to `Ts`. And this is indeed something we haven't talked about explicitly how to specify yet.
Most of the discussion of PEP 646 has taken place on typing-sig, so I'll start a new thread there to discuss this.