I have to write a function which looks like the following: def funci(x1, ..., xki) -> y1,...,ymi
, where all x
's and y
's have type TypeClass
.
Using typing
module, I could declare the function as: f(*args: TypeClass)
, but how to define the type of the variable-length returned values?
CodePudding user response:
From the typing
documentation,
To specify a variable-length tuple of homogeneous type, use literal ellipsis, e.g. Tuple[int, ...].
In your case, the return type should be Tuple[TypeClass, ...]
.