> It occurs to me that there's one other attribute that makes `tuple` special. It accepts zero-length lists (i.e. `tuple[()]`). Would the proposed variadic TypeVar mechanism also support this? For example, would `Tensor[()]` be legal?

Yes, zero-length Tuples are valid as arguments for Ts​. That is the case, for example, when we have def foo(*args: *Ts) -> Ts: ... and we call it with no arguments: foo()​. Ts​ would then resolve to Tuple[()]​. Likewise, Tensor[()]​ is also legal.

-- Pradeep


From: Eric Traut <eric@traut.com>
Sent: Monday, December 14, 2020 9:38 AM
To: typing-sig@python.org <typing-sig@python.org>
Subject: [Typing-sig] Re: Variadic generics PEP draft
 
Perhaps my choice of the term "arbitrary length" was confusing here. Alternatives might be "unknown length" or "unspecified length".

It occurs to me that there's one other attribute that makes `tuple` special. It accepts zero-length lists (i.e. `tuple[()]`). Would the proposed variadic TypeVar mechanism also support this? For example, would `Tensor[()]` be legal?

Perhaps `tuple` is just too much of an oddity for us to model using the proposed variadic TypeVar mechanism. I figured it was at least worth exploring the idea, so thanks for the discussion.

 -Eric
_______________________________________________
Typing-sig mailing list -- typing-sig@python.org
To unsubscribe send an email to typing-sig-leave@python.org
https://mail.python.org/mailman3/lists/typing-sig.python.org/
Member address: gohanpra@gmail.com