Re: list[type, type, ...] ?!

2020-12-03 Thread Paul Bryan
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 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 with respect to particular
> types -- that's left to the type checkers.
> 
> -- 
> Greg

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: list[type, type, ...] ?!

2020-12-03 Thread Greg Ewing

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?

--
Greg
--
https://mail.python.org/mailman/listinfo/python-list


Re: list[type, type, ...] ?!

2020-12-03 Thread Greg Ewing

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 with respect to particular
types -- that's left to the type checkers.

--
Greg
--
https://mail.python.org/mailman/listinfo/python-list