Thanks, Greg. Would it make sense for list's __class_getitem__
(GenericAlias?) to perform similar checking as
typing._SpecialGenericAlias (nparams)?
On Fri, 2020-12-04 at 12:15 +1300, Greg Ewing wrote:
> On 3/12/20 7:37 pm, Paul Bryan wrote:
> > > > > list[int, int]
> > list[int, int]
> >
> > In
On 4/12/20 12:31 pm, Paul Bryan wrote:
Would it make sense for list's __class_getitem__
(GenericAlias?) to perform similar checking as
typing._SpecialGenericAlias (nparams)?
Maybe. It's a slippery slope -- how much of the typing module do we
want to drag into the core of the interpreter?
--
On 3/12/20 7:37 pm, Paul Bryan wrote:
list[int, int]
list[int, int]
In fact, it appears I can specify an indeterminate number of types.
I think the built-in generic alias just provides the minimum
necessary to be able to write sometype[arg, ...]. It doesn't
know anything about the semantics
Using the typing.List generic alias, I can only specify a single type.
Example:
>>> typing.List[int]
typing.List[int]
When I try to specify additional types, it fails. Example:
>>> typing.List[int, int]
Traceback (most recent call last):
File "", line 1, in
File