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

Paul Bryan pbryan at anode.ca
Thu Dec 3 18:31:30 EST 2020


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



More information about the Python-list mailing list