Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How to return a variable number of values?

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?

>Solution :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

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, ...].

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading